aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-06-21 12:58:00 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-06-21 12:58:00 +0200
commitd54d1fc3bcd2d3dda563f9bd95b60299bc892041 (patch)
treea1bba68984c40a32b45cc159beb1301d2f80d6f7
parent9fe9816bcd72e5ae5fe374d7483e4b5b0c618b22 (diff)
downloadgcc-d54d1fc3bcd2d3dda563f9bd95b60299bc892041.zip
gcc-d54d1fc3bcd2d3dda563f9bd95b60299bc892041.tar.gz
gcc-d54d1fc3bcd2d3dda563f9bd95b60299bc892041.tar.bz2
re PR c++/81130 (ICE OpenMP shared clause in gimplify_var_or_parm_decl, at gimplify.c:2584)
PR c++/81130 * gimplify.c (omp_add_variable): Don't force GOVD_SEEN for types with ctors/dtors if GOVD_SHARED is set. * testsuite/libgomp.c++/pr81130.C: New test. From-SVN: r249445
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimplify.c8
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/testsuite/libgomp.c++/pr81130.C41
4 files changed, 57 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c9ee703..a40820b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/81130
+ * gimplify.c (omp_add_variable): Don't force GOVD_SEEN for types
+ with ctors/dtors if GOVD_SHARED is set.
+
2017-06-21 Wilco Dijkstra <wdijkstr@arm.com>
* config/aarch64/aarch64.md (movti_aarch64):
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index cf82f95..13760c0 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6634,9 +6634,11 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
return;
/* Never elide decls whose type has TREE_ADDRESSABLE set. This means
- there are constructors involved somewhere. */
- if (TREE_ADDRESSABLE (TREE_TYPE (decl))
- || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
+ there are constructors involved somewhere. Exception is a shared clause,
+ there is nothing privatized in that case. */
+ if ((flags & GOVD_SHARED) == 0
+ && (TREE_ADDRESSABLE (TREE_TYPE (decl))
+ || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))))
flags |= GOVD_SEEN;
n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 9f4b052..da9946f 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/81130
+ * testsuite/libgomp.c++/pr81130.C: New test.
+
2017-06-17 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* testsuite/libgomp.fortran/strassen.f90: Remove dg-skip-if
diff --git a/libgomp/testsuite/libgomp.c++/pr81130.C b/libgomp/testsuite/libgomp.c++/pr81130.C
new file mode 100644
index 0000000..f2cb571
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr81130.C
@@ -0,0 +1,41 @@
+// PR c++/81130
+// { dg-do run }
+
+struct A
+{
+ A ();
+ ~A ();
+ int a;
+};
+
+A::A ()
+{
+ a = 0;
+}
+
+A::~A ()
+{
+}
+
+struct B
+{
+ A b;
+ int c;
+ B () : c (1)
+ {
+#pragma omp parallel shared (b, c) num_threads (2)
+#pragma omp master
+ {
+ b.a++;
+ c += 2;
+ }
+ }
+};
+
+int
+main ()
+{
+ B v;
+ if (v.b.a != 1 || v.c != 3)
+ __builtin_abort ();
+}