summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-06-21 22:19:38 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-06-21 22:19:38 +0000
commit9605eca7cedeb9a89ea86cf19968f54437bb296b (patch)
tree3a3f544c1d6c04c48588f545490eec1161bed849
parent3fbdaf62a49f87e9784e7fffacd942e8835010a3 (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@249482 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/gimplify.c8
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/testsuite/libgomp.c++/pr81130.C41
4 files changed, 55 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 266ce7e147f0..71e3531e0448 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +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.
+
Backported from mainline
2017-06-20 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f98a28364899..b93993c7856b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6608,9 +6608,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 9ddbc91fdba0..30663e160ad3 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-02 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
diff --git a/libgomp/testsuite/libgomp.c++/pr81130.C b/libgomp/testsuite/libgomp.c++/pr81130.C
new file mode 100644
index 000000000000..f2cb571294d4
--- /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 ();
+}