https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100319
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:1b462deabf70e0f4bebb1f85118827d9c2eeffb5 commit r12-281-g1b462deabf70e0f4bebb1f85118827d9c2eeffb5 Author: Jakub Jelinek <ja...@redhat.com> Date: Thu Apr 29 11:11:37 2021 +0200 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 <ja...@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.