From: Jakub Jelinek Date: Thu, 8 Jun 2017 19:10:49 +0000 (+0200) Subject: re PR c/81006 (ICE with zero-size array and #pragma omp task depend) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8ab7005b1420687c0e31a28a4e6e9fd05bb7f22e;p=gcc.git re PR c/81006 (ICE with zero-size array and #pragma omp task depend) 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 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 0f23eb3773b..e94bcead994 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-06-08 Jakub Jelinek + + 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 * gimple-parser.c (c_parser_parse_gimple_body): Use TDI_gimple instead diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 92aab54d416..00e16e8e435 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12364,9 +12364,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec &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)) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bb0466d156d..38b04faf0e1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-06-08 Jakub Jelinek + 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 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 99c61e5fd3c..94de17f6e3e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4731,9 +4731,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec &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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 956f40005a1..ca0862640fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-06-08 Jakub Jelinek + 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 index 00000000000..a826c5f5a53 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr81006.c @@ -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" } */ + {} +}