diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-06-03 10:38:08 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-06-03 10:38:08 +0200 |
commit | 098f4e989beb1a1be1157430c56ea4f158c1d538 (patch) | |
tree | c4c9a0381fea204c577e7ebbb28eeef4c5e516e4 /gcc/tree-inline.c | |
parent | bff9a7ec6e3b8bf9d9635445c94e6c166e6f43e1 (diff) | |
download | gcc-098f4e989beb1a1be1157430c56ea4f158c1d538.zip gcc-098f4e989beb1a1be1157430c56ea4f158c1d538.tar.gz gcc-098f4e989beb1a1be1157430c56ea4f158c1d538.tar.bz2 |
openmp: Assorted depend/affinity/iterator related fixes [PR100859]
The depend-iterator-3.C testcases shows various bugs.
1) tsubst_omp_clauses didn't handle OMP_CLAUSE_AFFINITY (should be
handled like OMP_CLAUSE_DEPEND)
2) because locators can be arbitrary lvalue expressions, we need
to allow for C++ array section base (especially when array section
is just an array reference) FIELD_DECLs, handle them as this->member,
but don't need to privatize in any way
3) similarly for this as base
4) depend(inout: this) is invalid, but for different reason than the reported
one, again this is an expression, but not lvalue expression, so that
should be reported
5) the ctor/dtor cloning in the C++ FE (which is using walk_tree with
copy_tree_body_r) didn't handle iterators correctly, walk_tree normally
doesn't walk TREE_PURPOSE of TREE_LIST, and in the iterator case
that TREE_VEC contains also a BLOCK that needs special handling during
copy_tree_body_r
2021-06-03 Jakub Jelinek <jakub@redhat.com>
PR c++/100859
gcc/
* tree-inline.c (copy_tree_body_r): Handle iterators on
OMP_CLAUSE_AFFINITY or OMP_CLAUSE_DEPEND.
gcc/c/
* c-typeck.c (c_finish_omp_clauses): Move OMP_CLAUSE_AFFINITY
after depend only cases.
gcc/cp/
* semantics.c (handle_omp_array_sections_1): For
OMP_CLAUSE_{AFFINITY,DEPEND} handle FIELD_DECL base using
finish_non_static_data_member and allow this as base.
(finish_omp_clauses): Move OMP_CLAUSE_AFFINITY
after depend only cases. Let this be diagnosed by !lvalue_p
case for OMP_CLAUSE_{AFFINITY,DEPEND} and remove useless
assert.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_AFFINITY.
gcc/testsuite/
* g++.dg/gomp/depend-iterator-3.C: New test.
* g++.dg/gomp/this-1.C: Don't expect any diagnostics for
this as base expression of depend array section, expect a different
error wording for this as depend locator and add testcases
for affinity clauses.
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index d38e861..5396131 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1453,6 +1453,27 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) *walk_subtrees = 0; } + else if (TREE_CODE (*tp) == OMP_CLAUSE + && (OMP_CLAUSE_CODE (*tp) == OMP_CLAUSE_AFFINITY + || OMP_CLAUSE_CODE (*tp) == OMP_CLAUSE_DEPEND)) + { + tree t = OMP_CLAUSE_DECL (*tp); + if (TREE_CODE (t) == TREE_LIST + && TREE_PURPOSE (t) + && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC) + { + *walk_subtrees = 0; + OMP_CLAUSE_DECL (*tp) = copy_node (t); + t = OMP_CLAUSE_DECL (*tp); + TREE_PURPOSE (t) = copy_node (TREE_PURPOSE (t)); + for (int i = 0; i <= 4; i++) + walk_tree (&TREE_VEC_ELT (TREE_PURPOSE (t), i), + copy_tree_body_r, id, NULL); + if (TREE_VEC_ELT (TREE_PURPOSE (t), 5)) + remap_block (&TREE_VEC_ELT (TREE_PURPOSE (t), 5), id); + walk_tree (&TREE_VALUE (t), copy_tree_body_r, id, NULL); + } + } } /* Keep iterating. */ |