re PR c++/40975 (ICE in copy_tree_r on array new)
authorJason Merrill <jason@redhat.com>
Mon, 2 May 2011 21:59:57 +0000 (17:59 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 2 May 2011 21:59:57 +0000 (17:59 -0400)
PR c++/40975
* tree-inline.c (copy_tree_r): Handle STATEMENT_LIST.

From-SVN: r173273

gcc/ChangeLog
gcc/tree-inline.c

index da19a8f2b564449a36735a28c047e30c198d08d5..10d30a91eee57211b7dfdbc022157b969b1959e6 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-02  Jason Merrill  <jason@redhat.com>
+
+       PR c++/40975
+       * tree-inline.c (copy_tree_r): Handle STATEMENT_LIST.
+
 2011-05-02  Simon Martin  <simartin@users.sourceforge.net>
 
        PR c/35445
index 5da4a12d9ad6f0cca7444aef1fb5c6ab86dae9cc..37776753ca3a1d8c02b84f5b8bfb27da2eef2bf9 100644 (file)
@@ -4271,14 +4271,26 @@ 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).  */
+      tree new_list = alloc_stmt_list ();
+      tree_stmt_iterator i = tsi_start (*tp);
+      tree_stmt_iterator j = tsi_last (new_list);
+      for (; !tsi_end_p (i); tsi_next (&i))
+       {
+         tree stmt = tsi_stmt (i);
+         tsi_link_after (&j, stmt, TSI_CONTINUE_LINKING);
+       }
+      *tp = new_list;
+    }
   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;
 }