]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/88949
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Jan 2019 22:33:52 +0000 (22:33 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Jan 2019 22:33:52 +0000 (22:33 +0000)
* optimize.c (cxx_copy_decl): New function.
(clone_body): Use it instead of copy_decl_no_change.

* g++.dg/gomp/pr88949.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268127 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/optimize.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr88949.C [new file with mode: 0644]

index e5ce94c75e8edeb1ce0d7576d6daa10746dfd953..111782aeaba1ebd04313dd2f1c7263bd63d0be79 100644 (file)
@@ -1,5 +1,9 @@
 2019-01-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/88949
+       * optimize.c (cxx_copy_decl): New function.
+       (clone_body): Use it instead of copy_decl_no_change.
+
        PR sanitizer/88901
        * typeck.c (cp_build_binary_op): Don't instrument
        SANITIZE_POINTER_COMPARE if processing_template_decl.
index 40d0dcc39956653af395ed359752cf420adb42aa..7b6edfc0e4936579b5b1b2624394a07c2301ac47 100644 (file)
@@ -61,6 +61,25 @@ update_cloned_parm (tree parm, tree cloned_parm, bool first)
   DECL_GIMPLE_REG_P (cloned_parm) = DECL_GIMPLE_REG_P (parm);
 }
 
+/* Like copy_decl_no_change, but handle DECL_OMP_PRIVATIZED_MEMBER
+   properly.  */
+
+static tree
+cxx_copy_decl (tree decl, copy_body_data *id)
+{
+  tree copy = copy_decl_no_change (decl, id);
+  if (VAR_P (decl)
+      && DECL_HAS_VALUE_EXPR_P (decl)
+      && DECL_ARTIFICIAL (decl)
+      && DECL_LANG_SPECIFIC (decl)
+      && DECL_OMP_PRIVATIZED_MEMBER (decl))
+    {
+      tree expr = DECL_VALUE_EXPR (copy);
+      walk_tree (&expr, copy_tree_body_r, id, NULL);
+      SET_DECL_VALUE_EXPR (copy, expr);
+    }
+  return copy;
+}
 
 /* FN is a function in High GIMPLE form that has a complete body and no
    CFG.  CLONE is a function whose body is to be set to a copy of FN,
@@ -80,7 +99,7 @@ clone_body (tree clone, tree fn, void *arg_map)
   id.src_cfun = DECL_STRUCT_FUNCTION (fn);
   id.decl_map = static_cast<hash_map<tree, tree> *> (arg_map);
 
-  id.copy_decl = copy_decl_no_change;
+  id.copy_decl = cxx_copy_decl;
   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   id.transform_new_cfg = true;
   id.transform_return_to_modify = false;
index ce462ac79d9d71d00426c79f289869cdba6c88d3..86910c2b4f75430f528e073faee60dd37d19ec4b 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88949
+       * g++.dg/gomp/pr88949.C: New test.
+
 2019-01-21  Manfred Schwarb  <manfred99@gmx.ch>
 
        * class_66.f90: Fix a dg directive.
diff --git a/gcc/testsuite/g++.dg/gomp/pr88949.C b/gcc/testsuite/g++.dg/gomp/pr88949.C
new file mode 100644 (file)
index 0000000..04d2415
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/88949
+// { dg-do compile }
+
+struct A {
+  int a;
+  A (int x) : a (x) {
+#pragma omp parallel firstprivate (a)
+    --a;
+  }
+  void foo () {
+#pragma omp parallel firstprivate (a)
+    --a;
+  }
+};
+
+int c;
+
+int
+main ()
+{
+  A d(c);
+  d.foo ();
+}