aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-11-04 09:37:22 +0100
committerJakub Jelinek <jakub@redhat.com>2020-11-04 10:02:01 +0100
commit9649031577028310e853025672c71dfb500494f0 (patch)
tree77628998c8b1cfcf5d767872248ff33542eff532 /gcc/cp/semantics.c
parent7988c76ebacd66741110886c3dc7a4f0245ba9b5 (diff)
downloadgcc-9649031577028310e853025672c71dfb500494f0.zip
gcc-9649031577028310e853025672c71dfb500494f0.tar.gz
gcc-9649031577028310e853025672c71dfb500494f0.tar.bz2
openmp: allocate clause vs. *reduction array sections [PR97670]
This patch finds the base expression of reduction array sections and uses it in checks whether allocate clause lists only variables that have been privatized. Also fixes a pasto that caused an ICE. 2020-11-04 Jakub Jelinek <jakub@redhat.com> PR c++/97670 gcc/c-family/ * c-omp.c (c_omp_split_clauses): Look through array reductions to find underlying decl to clear in the allocate_head bitmap. gcc/c/ * c-typeck.c (c_finish_omp_clauses): Look through array reductions to find underlying decl to clear in the aligned_head bitmap. gcc/cp/ * semantics.c (finish_omp_clauses): Look through array reductions to find underlying decl to clear in the aligned_head bitmap. Use DECL_UID (t) instead of DECL_UID (OMP_CLAUSE_DECL (c)) when clearing in the bitmap. Only diagnose errors about allocate vars not being privatized on the same construct on allocate clause if it has a DECL_P OMP_CLAUSE_DECL. gcc/testsuite/ * c-c++-common/gomp/allocate-4.c: New test. * g++.dg/gomp/allocate-2.C: New test. * g++.dg/gomp/allocate-3.C: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 352ebe0..a550db6 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8190,17 +8190,11 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
t = OMP_CLAUSE_DECL (c);
- if (processing_template_decl
- && !VAR_P (t) && TREE_CODE (t) != PARM_DECL)
- {
- pc = &OMP_CLAUSE_CHAIN (c);
- continue;
- }
-
switch (c_kind)
{
case OMP_CLAUSE_LASTPRIVATE:
- if (!bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
+ if (DECL_P (t)
+ && !bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
{
need_default_ctor = true;
need_dtor = true;
@@ -8210,6 +8204,34 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
case OMP_CLAUSE_REDUCTION:
case OMP_CLAUSE_IN_REDUCTION:
case OMP_CLAUSE_TASK_REDUCTION:
+ if (allocate_seen)
+ {
+ if (TREE_CODE (t) == MEM_REF)
+ {
+ t = TREE_OPERAND (t, 0);
+ if (TREE_CODE (t) == POINTER_PLUS_EXPR)
+ t = TREE_OPERAND (t, 0);
+ if (TREE_CODE (t) == ADDR_EXPR
+ || TREE_CODE (t) == INDIRECT_REF)
+ t = TREE_OPERAND (t, 0);
+ if (DECL_P (t))
+ bitmap_clear_bit (&aligned_head, DECL_UID (t));
+ }
+ else if (TREE_CODE (t) == TREE_LIST)
+ {
+ while (TREE_CODE (t) == TREE_LIST)
+ t = TREE_CHAIN (t);
+ if (DECL_P (t))
+ bitmap_clear_bit (&aligned_head, DECL_UID (t));
+ t = OMP_CLAUSE_DECL (c);
+ }
+ else if (DECL_P (t))
+ bitmap_clear_bit (&aligned_head, DECL_UID (t));
+ t = OMP_CLAUSE_DECL (c);
+ }
+ if (processing_template_decl
+ && !VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ break;
if (finish_omp_reduction_clause (c, &need_default_ctor,
&need_dtor))
remove = true;
@@ -8218,6 +8240,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break;
case OMP_CLAUSE_COPYIN:
+ if (processing_template_decl
+ && !VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ break;
if (!VAR_P (t) || !CP_DECL_THREAD_LOCAL_P (t))
{
error_at (OMP_CLAUSE_LOCATION (c),
@@ -8230,6 +8255,13 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break;
}
+ if (processing_template_decl
+ && !VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ {
+ pc = &OMP_CLAUSE_CHAIN (c);
+ continue;
+ }
+
if (need_complete_type || need_copy_assignment)
{
t = require_complete_type (t);
@@ -8247,8 +8279,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (allocate_seen
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
&& DECL_P (t))
- bitmap_clear_bit (&aligned_head,
- DECL_UID (OMP_CLAUSE_DECL (c)));
+ bitmap_clear_bit (&aligned_head, DECL_UID (t));
if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t))
share_name = "threadprivate";
@@ -8349,6 +8380,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
bool remove = false;
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE
&& !OMP_CLAUSE_ALLOCATE_COMBINED (c)
+ && DECL_P (OMP_CLAUSE_DECL (c))
&& bitmap_bit_p (&aligned_head, DECL_UID (OMP_CLAUSE_DECL (c))))
{
error_at (OMP_CLAUSE_LOCATION (c),