diff mbox series

[committed] openmp: c++: Consider typeinfo decls to be predetermined shared [PR91118]

Message ID 20200129085345.GE17695@tucnak
State New
Headers show
Series [committed] openmp: c++: Consider typeinfo decls to be predetermined shared [PR91118] | expand

Commit Message

Jakub Jelinek Jan. 29, 2020, 8:53 a.m. UTC
Hi!

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.

This patch makes those predetermined shared.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

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.


	Jakub
diff mbox series

Patch

--- gcc/cp/cp-gimplify.c.jj	2020-01-15 00:26:26.563527365 +0100
+++ gcc/cp/cp-gimplify.c	2020-01-28 13:24:11.821423237 +0100
@@ -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;
 }
 
--- gcc/testsuite/g++.dg/gomp/pr91118-1.C.jj	2020-01-28 13:38:22.450743210 +0100
+++ gcc/testsuite/g++.dg/gomp/pr91118-1.C	2020-01-28 13:41:00.557385504 +0100
@@ -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;
+}
--- gcc/testsuite/g++.dg/gomp/pr91118-2.C.jj	2020-01-28 13:39:29.055749988 +0100
+++ gcc/testsuite/g++.dg/gomp/pr91118-2.C	2020-01-28 13:39:46.446490655 +0100
@@ -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));
+}