]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/81006 (ICE with zero-size array and #pragma omp task depend)
authorJakub Jelinek <jakub@redhat.com>
Thu, 8 Jun 2017 19:13:51 +0000 (21:13 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 8 Jun 2017 19:13:51 +0000 (21:13 +0200)
PR c/81006
* c-typeck.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE
to sizetype before size_binop.

* semantics.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE
to sizetype before size_binop.

* c-c++-common/gomp/pr81006.c: New test.

From-SVN: r249037

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr81006.c [new file with mode: 0644]

index 1c7b18dddc29f1f75568e8228957ce0f77fd55a7..1c5ad59c87a2d48d9ee5e4223cf8ec80b04c4c07 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/81006
+       * c-typeck.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE
+       to sizetype before size_binop.
+
 2017-05-05  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index c2b08ab32ee8e9628f0ce6e586890ba125f16309..4119eec22fe103f4033c0bcdde68d1331640c656 100644 (file)
@@ -12087,9 +12087,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
          && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
                        == INTEGER_CST)
        {
-         tree size = size_binop (PLUS_EXPR,
-                                 TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
-                                 size_one_node);
+         tree size
+           = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+         size = size_binop (PLUS_EXPR, size, size_one_node);
          if (TREE_CODE (low_bound) == INTEGER_CST)
            {
              if (tree_int_cst_lt (size, low_bound))
index ab298cf179c87b5f83143416a797f4f5c3bd6fd8..c19900bfb262eae8b51546481a4678922c706147 100644 (file)
@@ -1,5 +1,9 @@
 2017-06-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/81006
+       * semantics.c (handle_omp_array_sections_1): Convert TYPE_MAX_VALUE
+       to sizetype before size_binop.
+
        PR c++/81011
        * cp-gimplify.c (cxx_omp_finish_clause): When changing clause
        to OMP_CLAUSE_SHARED, also clear OMP_CLAUSE_SHARED_FIRSTPRIVATE
index 2c831bc305397f28aa26ce358641258ea193bf7b..991f0fbe4069c5b74de70b7f7b9e75211071e210 100644 (file)
@@ -4675,9 +4675,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
          && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
                        == INTEGER_CST)
        {
-         tree size = size_binop (PLUS_EXPR,
-                                 TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
-                                 size_one_node);
+         tree size
+           = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+         size = size_binop (PLUS_EXPR, size, size_one_node);
          if (TREE_CODE (low_bound) == INTEGER_CST)
            {
              if (tree_int_cst_lt (size, low_bound))
index 7672bb813b6ae3efda3c4bd77dd2f0aa284c199c..368fee3a5d7d2efbc04e21f13f41c8f7e8012319 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/81006
+       * c-c++-common/gomp/pr81006.c: New test.
+
        PR c++/81011
        * g++.dg/gomp/pr81011.C: New test.
 
diff --git a/gcc/testsuite/c-c++-common/gomp/pr81006.c b/gcc/testsuite/c-c++-common/gomp/pr81006.c
new file mode 100644 (file)
index 0000000..a826c5f
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR c/81006 */
+/* { dg-do compile } */
+
+int a[] = {};
+
+void foo()
+{
+  #pragma omp task depend(out: a[:])   /* { dg-error "zero length array section in .depend. clause" } */
+    {}
+}