diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-04-29 11:11:37 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-04-29 11:11:37 +0200 |
commit | 1b462deabf70e0f4bebb1f85118827d9c2eeffb5 (patch) | |
tree | ebf9101771dff41bf9e4782ded4a8fc67a198797 /gcc | |
parent | c57a8aea0c3ab8394f7dbfa417ee27b4613f63b7 (diff) | |
download | gcc-1b462deabf70e0f4bebb1f85118827d9c2eeffb5.zip gcc-1b462deabf70e0f4bebb1f85118827d9c2eeffb5.tar.gz gcc-1b462deabf70e0f4bebb1f85118827d9c2eeffb5.tar.bz2 |
c++: Fix up detach clause vs. data-sharing clause checking [PR100319]
The standard says that "The event-handle will be considered as if it
was specified on a firstprivate clause." which means that it can't
be explicitly specified in some other data-sharing clause.
The checking is implemented correctly for C, but for C++ when detach_seen
is true (i.e. the construct had detach clause) we were comparing
OMP_CLAUSE_DECL (c) with t, which was previously initialized to
OMP_CLAUSE_DECL (c), which means it complained about any explicit
data-sharing clause on the same construct with a detach clause.
Fixed by remembering the detach clause in detach_seen (instead of a boolean
flag) and comparing against its OMP_CLAUSE_DECL.
2021-04-29 Jakub Jelinek <jakub@redhat.com>
PR c++/100319
* semantics.c (finish_omp_clauses): Fix up check that variable
mentioned in detach clause doesn't appear in data-sharing clauses.
* c-c++-common/gomp/task-detach-3.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/semantics.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/task-detach-3.c | 19 |
2 files changed, 22 insertions, 3 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4520181..3a6468f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6527,7 +6527,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) has been seen, -2 if mixed inscan/normal reduction diagnosed. */ int reduction_seen = 0; bool allocate_seen = false; - bool detach_seen = false; + tree detach_seen = NULL_TREE; bool mergeable_seen = false; bitmap_obstack_initialize (NULL); @@ -7578,7 +7578,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) type); remove = true; } - detach_seen = true; + detach_seen = c; cxx_mark_addressable (t); } break; @@ -8548,7 +8548,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE) - && OMP_CLAUSE_DECL (c) == t) + && OMP_CLAUSE_DECL (c) == OMP_CLAUSE_DECL (detach_seen)) { error_at (OMP_CLAUSE_LOCATION (c), "the event handle of a %<detach%> clause " diff --git a/gcc/testsuite/c-c++-common/gomp/task-detach-3.c b/gcc/testsuite/c-c++-common/gomp/task-detach-3.c new file mode 100644 index 0000000..97e622d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/task-detach-3.c @@ -0,0 +1,19 @@ +/* PR c++/100319 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +typedef enum omp_event_handle_t +{ + __omp_event_handle_t_max__ = __UINTPTR_MAX__ +} omp_event_handle_t; + +extern void omp_fulfill_event (omp_event_handle_t); + +void f (omp_event_handle_t x, omp_event_handle_t y, int z) +{ + #pragma omp task detach (x) firstprivate (y, z) /* { dg-bogus "the event handle of a 'detach' clause should not be in a data-sharing clause" } */ + ; + + #pragma omp task detach (x) shared (y) /* { dg-bogus "the event handle of a 'detach' clause should not be in a data-sharing clause" } */ + ; +} |