]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/88949 (ICE in expand_expr_real_1, at expr.c:10001 with -fopenmp)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:29:04 +0000 (13:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:29:04 +0000 (13:29 +0200)
Backported from mainline
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.

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

From-SVN: r275089

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

index 92d49aecfdba7fa9afdd33db2ab12da6c01897ce..1e60d3a52c91f2186ce6e480d1e06f885524b6e7 100644 (file)
@@ -1,6 +1,12 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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.
+
        2018-12-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/86669
index 7cca0135360997fda80479c734b9935bb18e8c6e..17b7f6ee7280cfe707906a215c9e6c8426771702 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 7f228b8e7a84dc6a21e0fe39f08e9a4fdedcaef6..1c551a8be24c2820869b70430b291799716d93c9 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-01-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88949
+       * g++.dg/gomp/pr88949.C: New test.
+
        2019-01-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/88902
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 ();
+}