Hi! If we can't copy construct, or destruct etc. a privatized variable, for error-recovery we turn it into a shared clause that doesn't need that. But starting with GCC 6 there are two OMP_CLAUSE_SHARED_* bits that mean something different on other clauses, so we need to clear them.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk and 7.x/6.x. 2017-06-08 Jakub Jelinek <ja...@redhat.com> PR c++/81011 * cp-gimplify.c (cxx_omp_finish_clause): When changing clause to OMP_CLAUSE_SHARED, also clear OMP_CLAUSE_SHARED_FIRSTPRIVATE and OMP_CLAUSE_SHARED_READONLY flags. * g++.dg/gomp/pr81011.C: New test. --- gcc/cp/cp-gimplify.c.jj 2017-06-07 10:45:32.000000000 +0200 +++ gcc/cp/cp-gimplify.c 2017-06-08 13:24:48.639272627 +0200 @@ -1912,7 +1912,11 @@ cxx_omp_finish_clause (tree c, gimple_se make_shared = true; if (make_shared) - OMP_CLAUSE_CODE (c) = OMP_CLAUSE_SHARED; + { + OMP_CLAUSE_CODE (c) = OMP_CLAUSE_SHARED; + OMP_CLAUSE_SHARED_FIRSTPRIVATE (c) = 0; + OMP_CLAUSE_SHARED_READONLY (c) = 0; + } } /* Return true if DECL's DECL_VALUE_EXPR (if any) should be --- gcc/testsuite/g++.dg/gomp/pr81011.C.jj 2017-06-08 13:33:28.226656742 +0200 +++ gcc/testsuite/g++.dg/gomp/pr81011.C 2017-06-08 13:33:07.000000000 +0200 @@ -0,0 +1,19 @@ +// PR c++/81011 +// { dg-do compile } + +class A { A (const A&); }; // { dg-message "declared private here" } +void foo (const A&); + +void +bar (A& a) +{ +#pragma omp task // { dg-error "is private within this context" } + foo (a); +} + +void +baz (A& a) +{ +#pragma omp task firstprivate (a) // { dg-error "is private within this context" } + foo (a); +} Jakub