re PR c/81006 (ICE with zero-size array and #pragma omp task depend)
authorJakub Jelinek <jakub@redhat.com>
Thu, 8 Jun 2017 19:10:49 +0000 (21:10 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 8 Jun 2017 19:10:49 +0000 (21:10 +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: r249035

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 0f23eb3773b6391c1e1b7d7e5230c8761f51305a..e94bcead994e75c65a46ac5d028a8142a3725ea9 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-06-07  Jakub Jelinek  <jakub@redhat.com>
 
        * gimple-parser.c (c_parser_parse_gimple_body): Use TDI_gimple instead
index 92aab54d41621b3e3cc9184c22800ca6610717ce..00e16e8e4350c3c9452100858e5a0de59c18cb61 100644 (file)
@@ -12364,9 +12364,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 bb0466d156d370eccfd6e8dd9b7f267dccf6deda..38b04faf0e1223f04b1d46f3ee33390bc8194c6a 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 99c61e5fd3c2067a71cafb2135c36936bdeb22b5..94de17f6e3e4da546a0a4814aea9172028ba803c 100644 (file)
@@ -4731,9 +4731,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 956f40005a13a2332d17c55cb3bafb51c0172c77..ca0862640fafb349af51dfa4d0f0006b42bbeb3b 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" } */
+    {}
+}