]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/40975 (ICE in copy_tree_r on array new)
authorJason Merrill <jason@redhat.com>
Thu, 5 May 2011 21:02:51 +0000 (17:02 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 5 May 2011 21:02:51 +0000 (17:02 -0400)
PR c++/40975
* tree-inline.c (copy_tree_r): Handle STATEMENT_LIST.

From-SVN: r173454

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/new30.C [new file with mode: 0644]
gcc/tree-inline.c

index 2e432cf30b4d24b1f01ca013392af284f30cda2f..fe0fc6a1146fc3636133cb8f69991fd37b7e71c6 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-05  Jason Merrill  <jason@redhat.com>
+
+       PR c++/40975
+       * tree-inline.c (copy_tree_r): Handle STATEMENT_LIST.
+
 2011-05-05  Julian Brown  <julian@codesourcery.com>
 
        * config/arm/neon.md (vec_set<mode>_internal): Fix misplaced
index c3edc6533a2a0e2a627165bc98a94b7a05b0889b..a3db91f31bfc5eca6eb1e820f094aec546203f34 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-05  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/init/new30.C: New.
+
 2011-05-05  Julian Brown  <julian@codesourcery.com>
 
        * gcc.target/arm/neon-vset_lanes8.c: New test.
diff --git a/gcc/testsuite/g++.dg/init/new30.C b/gcc/testsuite/g++.dg/init/new30.C
new file mode 100644 (file)
index 0000000..24582d8
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/40975
+
+struct data_type
+{
+    // constructor required to reproduce compiler bug
+    data_type() {}
+};
+
+struct ptr_type
+{
+    // array new as default argument required to reproduce compiler bug
+    ptr_type (data_type* ptr = new data_type[1]) { delete[] ptr; }
+};
+
+ptr_type obj;
index 29fef96f77f68c43bcd67728ba84961d7dddcc37..a581e5c8c76fce33685624838de532dcd775d176 100644 (file)
@@ -3722,14 +3722,16 @@ copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
                                         CONSTRUCTOR_ELTS (*tp));
       *tp = new_tree;
     }
+  else if (code == STATEMENT_LIST)
+    /* We used to just abort on STATEMENT_LIST, but we can run into them
+       with statement-expressions (c++/40975).  */
+    copy_statement_list (tp);
   else if (TREE_CODE_CLASS (code) == tcc_type)
     *walk_subtrees = 0;
   else if (TREE_CODE_CLASS (code) == tcc_declaration)
     *walk_subtrees = 0;
   else if (TREE_CODE_CLASS (code) == tcc_constant)
     *walk_subtrees = 0;
-  else
-    gcc_assert (code != STATEMENT_LIST);
   return NULL_TREE;
 }