aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-27 09:16:48 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-27 09:16:48 +0200
commit6b0f35299bd1468ebc13b900a73b7cac6181a2aa (patch)
treed3fb9325a061bdb52e21c910f125f8ec8d28c158 /gcc/cp/semantics.c
parent7473b8a90490e1dcd8fd5f7a92307d79fd2a5f8e (diff)
downloadgcc-6b0f35299bd1468ebc13b900a73b7cac6181a2aa.zip
gcc-6b0f35299bd1468ebc13b900a73b7cac6181a2aa.tar.gz
gcc-6b0f35299bd1468ebc13b900a73b7cac6181a2aa.tar.bz2
openmp: Don't reject some valid initializers or conditions of non-rectangular loops [PR102854]
In C++, if an iterator has or might have (e.g. dependent type) class type we remember the original init expressions and check those separately for presence of iterators, because for class iterators we turn those into expressions that always do contain reference to the current iterator. But this resulted in rejecting valid non-rectangular loop where the dependent type is later instantiated to an integral type. Non-rectangular loops with class random access iterators remain broken, that is something to be fixed incrementally. 2021-10-27 Jakub Jelinek <jakub@redhat.com> PR c++/102854 gcc/c-family/ * c-common.h (c_omp_check_loop_iv_exprs): Add enum tree_code argument. * c-omp.c (c_omp_check_loop_iv_r): For trees other than decls, TREE_VEC, PLUS_EXPR, MINUS_EXPR, MULT_EXPR, POINTER_PLUS_EXPR or conversions temporarily clear the 3rd bit from d->kind while walking subtrees. (c_omp_check_loop_iv_exprs): Add CODE argument. Or in 4 into data.kind if possibly non-rectangular. gcc/cp/ * semantics.c (handle_omp_for_class_iterator, finish_omp_for): Adjust c_omp_check_loop_iv_exprs caller. gcc/testsuite/ * g++.dg/gomp/loop-3.C: Don't expect some errors. * g++.dg/gomp/loop-7.C: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0d8e5fd..3072ecd 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9211,7 +9211,7 @@ handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code,
TREE_OPERAND (cond, 1), iter);
return true;
}
- if (!c_omp_check_loop_iv_exprs (locus, orig_declv, i,
+ if (!c_omp_check_loop_iv_exprs (locus, code, orig_declv, i,
TREE_VEC_ELT (declv, i), NULL_TREE,
cond, cp_walk_subtrees))
return true;
@@ -9597,7 +9597,7 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv,
tree orig_init;
FOR_EACH_VEC_ELT (*orig_inits, i, orig_init)
if (orig_init
- && !c_omp_check_loop_iv_exprs (locus,
+ && !c_omp_check_loop_iv_exprs (locus, code,
orig_declv ? orig_declv : declv, i,
TREE_VEC_ELT (declv, i), orig_init,
NULL_TREE, cp_walk_subtrees))