]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: c++: Consider typeinfo decls to be predetermined shared [PR91118]
authorJakub Jelinek <jakub@redhat.com>
Wed, 29 Jan 2020 08:41:42 +0000 (09:41 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 13 Feb 2020 20:31:01 +0000 (21:31 +0100)
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  <jakub@redhat.com>

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
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr91118-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/pr91118-2.C [new file with mode: 0644]

index 64ca338029ba657b941ce089b1893bf44747efd8..31dee033f6eac8fdd28134ce07c9820ae1fd1f88 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2020-01-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/91118
+       * cp-gimplify.c (cxx_omp_predetermined_sharing): Return
+       OMP_CLAUSE_DEFAULT_SHARED for typeinfo decls.
+
 2020-01-28  Jason Merrill  <jason@redhat.com>
 
        PR c++/90546
index a7121b70a3b3b65b8aef12735487c447bf86ae18..90a315003d49d4984046fd522dace77cc4d33a82 100644 (file)
@@ -2107,6 +2107,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;
 }
 
index b5165efbc350e9a817339b06d6fef4f53883ae68..62df3f97f49e1dfa122a6b1ea1d7ea9a4bdd8b5c 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2020-01-29  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..f29d69d
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/91118
+// { dg-do compile }
+// { dg-additional-options "-fsanitize=undefined" }
+
+#include <iostream>
+
+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 (file)
index 0000000..80f1e3e
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/91118
+// { dg-do compile }
+
+#include <typeinfo>
+
+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));
+}