diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-07-27 21:13:42 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-07-27 21:13:42 +0200 |
commit | a40ff0ae8b8d28d5713792ca108f688f2ca4825a (patch) | |
tree | 8e297a3f30cbc148915200b3e303439c75bae8c3 /gcc | |
parent | 1f9e09b55416098b04b3071549cdd53ab95ff8b5 (diff) | |
download | gcc-a40ff0ae8b8d28d5713792ca108f688f2ca4825a.zip gcc-a40ff0ae8b8d28d5713792ca108f688f2ca4825a.tar.gz gcc-a40ff0ae8b8d28d5713792ca108f688f2ca4825a.tar.bz2 |
re PR c/45784 (gcc OpenMP - error: invalid controlling predicate)
PR c/45784
* c-omp.c (c_finish_omp_for): If the condition is wrapped in
rhs of COMPOUND_EXPR(s), skip them and readd their lhs into
new COMPOUND_EXPRs around the rhs of the comparison.
* testsuite/libgomp.c/pr45784.c: New test.
* testsuite/libgomp.c++/pr45784.C: New test.
From-SVN: r250635
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c-omp.c | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 12683a6..c05ca12 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2017-07-27 Jakub Jelinek <jakub@redhat.com> + + PR c/45784 + * c-omp.c (c_finish_omp_for): If the condition is wrapped in + rhs of COMPOUND_EXPR(s), skip them and readd their lhs into + new COMPOUND_EXPRs around the rhs of the comparison. + 2017-07-27 Marek Polacek <polacek@redhat.com> PR c/81417 diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 519c4e4..977cb0e 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -531,6 +531,12 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, { bool cond_ok = false; + /* E.g. C sizeof (vla) could add COMPOUND_EXPRs with + evaluation of the vla VAR_DECL. We need to readd + them to the non-decl operand. See PR45784. */ + while (TREE_CODE (cond) == COMPOUND_EXPR) + cond = TREE_OPERAND (cond, 1); + if (EXPR_HAS_LOCATION (cond)) elocus = EXPR_LOCATION (cond); @@ -605,6 +611,21 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, else if (code != CILK_SIMD && code != CILK_FOR) cond_ok = false; } + + if (cond_ok && TREE_VEC_ELT (condv, i) != cond) + { + tree ce = NULL_TREE, *pce = &ce; + tree type = TREE_TYPE (TREE_OPERAND (cond, 1)); + for (tree c = TREE_VEC_ELT (condv, i); c != cond; + c = TREE_OPERAND (c, 1)) + { + *pce = build2 (COMPOUND_EXPR, type, TREE_OPERAND (c, 0), + TREE_OPERAND (cond, 1)); + pce = &TREE_OPERAND (*pce, 1); + } + TREE_OPERAND (cond, 1) = ce; + TREE_VEC_ELT (condv, i) = cond; + } } if (!cond_ok) |