From 8d7c0bf876fa784101f9ad9e3bba82cc065357da Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 29 Jan 2020 09:41:42 +0100 Subject: [PATCH] openmp: c++: Consider typeinfo decls to be predetermined shared [PR91118] If the typeinfo decls appear in OpenMP default(none) regions, as we no longer predetermine const with no mutable members, they are diagnosed as errors, but it isn't something the users can actually provide explicit sharing for in the clauses. 2020-01-29 Jakub Jelinek PR c++/91118 * cp-gimplify.c (cxx_omp_predetermined_sharing): Return OMP_CLAUSE_DEFAULT_SHARED for typeinfo decls. * g++.dg/gomp/pr91118-1.C: New test. * g++.dg/gomp/pr91118-2.C: New test. --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-gimplify.c | 4 ++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/gomp/pr91118-1.C | 12 ++++++++++++ gcc/testsuite/g++.dg/gomp/pr91118-2.C | 14 ++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/g++.dg/gomp/pr91118-1.C create mode 100644 gcc/testsuite/g++.dg/gomp/pr91118-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9392c850750..4dcdb0428f1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-29 Jakub Jelinek + + PR c++/91118 + * cp-gimplify.c (cxx_omp_predetermined_sharing): Return + OMP_CLAUSE_DEFAULT_SHARED for typeinfo decls. + 2020-01-28 Jason Merrill PR c++/93442 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index f3aeb7475da..4fb3a1a8b8a 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -2187,6 +2187,10 @@ cxx_omp_predetermined_sharing (tree decl) && DECL_OMP_PRIVATIZED_MEMBER (decl))) return OMP_CLAUSE_DEFAULT_SHARED; + /* Similarly for typeinfo symbols. */ + if (VAR_P (decl) && DECL_ARTIFICIAL (decl) && DECL_TINFO_P (decl)) + return OMP_CLAUSE_DEFAULT_SHARED; + return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d13de9a3f84..01aaaf509da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2020-01-29 Jakub Jelinek + PR c++/91118 + * g++.dg/gomp/pr91118-1.C: New test. + * g++.dg/gomp/pr91118-2.C: New test. + PR fortran/93463 * gfortran.dg/goacc/pr93463.f90: New test. diff --git a/gcc/testsuite/g++.dg/gomp/pr91118-1.C b/gcc/testsuite/g++.dg/gomp/pr91118-1.C new file mode 100644 index 00000000000..f29d69db084 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr91118-1.C @@ -0,0 +1,12 @@ +// PR c++/91118 +// { dg-do compile } +// { dg-additional-options "-fsanitize=undefined" } + +#include + +void +foo () +{ +#pragma omp parallel default(none) shared(std::cerr) + std::cerr << "hello" << std::endl; +} diff --git a/gcc/testsuite/g++.dg/gomp/pr91118-2.C b/gcc/testsuite/g++.dg/gomp/pr91118-2.C new file mode 100644 index 00000000000..80f1e3e45c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr91118-2.C @@ -0,0 +1,14 @@ +// PR c++/91118 +// { dg-do compile } + +#include + +struct S { virtual ~S (); }; +void bar (const std::type_info &, const std::type_info &); + +void +foo (S *p) +{ + #pragma omp parallel default (none) firstprivate (p) + bar (typeid (*p), typeid (S)); +} -- 2.30.2