aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-10-30 09:16:45 +0100
committerJakub Jelinek <jakub@redhat.com>2020-10-30 09:16:45 +0100
commit5a6b1d8ef4218a1a2ed6d43c6ee058db9c417bc8 (patch)
treecb6feb912772a61d80a954d525c48a08da8aa7c4 /gcc/cp
parent973574465ca250ed9af5c229a8a3a6b05fde9ca0 (diff)
downloadgcc-5a6b1d8ef4218a1a2ed6d43c6ee058db9c417bc8.zip
gcc-5a6b1d8ef4218a1a2ed6d43c6ee058db9c417bc8.tar.gz
gcc-5a6b1d8ef4218a1a2ed6d43c6ee058db9c417bc8.tar.bz2
openmp: Handle non-static data members in allocate clause and other C++ allocate fixes
This allows specification of non-static data members in allocate clause like it can be specified in other privatization clauses and adds a new testcase that covers also handling of that clause in templates. 2020-10-30 Jakub Jelinek <jakub@redhat.com> * semantics.c (finish_omp_clauses) <case OMP_CLAUSE_ALLOCATE>: Handle non-static members in methods. * pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_ALLOCATE. * c-c++-common/gomp/allocate-1.c (qux): Add another test. * g++.dg/gomp/allocate-1.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.c1
-rw-r--r--gcc/cp/semantics.c33
2 files changed, 21 insertions, 13 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b569644..aa162d2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -17390,6 +17390,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
case OMP_CLAUSE_IS_DEVICE_PTR:
case OMP_CLAUSE_INCLUSIVE:
case OMP_CLAUSE_EXCLUSIVE:
+ case OMP_CLAUSE_ALLOCATE:
/* tsubst_expr on SCOPE_REF results in returning
finish_non_static_data_member result. Undo that here. */
if (TREE_CODE (OMP_CLAUSE_DECL (oc)) == SCOPE_REF
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d8d3baf92..352ebe0 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7200,7 +7200,11 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break;
case OMP_CLAUSE_ALLOCATE:
- t = OMP_CLAUSE_DECL (c);
+ t = omp_clause_decl_field (OMP_CLAUSE_DECL (c));
+ if (t)
+ omp_note_field_privatization (t, OMP_CLAUSE_DECL (c));
+ else
+ t = OMP_CLAUSE_DECL (c);
if (t == current_class_ptr)
{
error_at (OMP_CLAUSE_LOCATION (c),
@@ -7208,7 +7212,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
remove = true;
break;
}
- if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ if (!VAR_P (t)
+ && TREE_CODE (t) != PARM_DECL
+ && TREE_CODE (t) != FIELD_DECL)
{
if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
break;
@@ -7232,17 +7238,18 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
bitmap_set_bit (&aligned_head, DECL_UID (t));
allocate_seen = true;
}
- t = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c);
- if (error_operand_p (t))
+ tree allocator;
+ allocator = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c);
+ if (error_operand_p (allocator))
{
remove = true;
break;
}
- if (t == NULL_TREE)
- break;
+ if (allocator == NULL_TREE)
+ goto handle_field_decl;
tree allocatort;
- allocatort = TYPE_MAIN_VARIANT (TREE_TYPE (t));
- if (!type_dependent_expression_p (t)
+ allocatort = TYPE_MAIN_VARIANT (TREE_TYPE (allocator));
+ if (!type_dependent_expression_p (allocator)
&& (TREE_CODE (allocatort) != ENUMERAL_TYPE
|| TYPE_NAME (allocatort) == NULL_TREE
|| TREE_CODE (TYPE_NAME (allocatort)) != TYPE_DECL
@@ -7254,17 +7261,17 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
error_at (OMP_CLAUSE_LOCATION (c),
"%<allocate%> clause allocator expression has "
"type %qT rather than %<omp_allocator_handle_t%>",
- TREE_TYPE (t));
+ TREE_TYPE (allocator));
remove = true;
}
else
{
- t = mark_rvalue_use (t);
+ allocator = mark_rvalue_use (allocator);
if (!processing_template_decl)
- t = maybe_constant_value (t);
- OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) = t;
+ allocator = maybe_constant_value (allocator);
+ OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) = allocator;
}
- break;
+ goto handle_field_decl;
case OMP_CLAUSE_DEPEND:
t = OMP_CLAUSE_DECL (c);