diff mbox

RFA Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

Message ID 4DC0470D.9090303@redhat.com
State New
Headers show

Commit Message

Jason Merrill May 3, 2011, 6:18 p.m. UTC
On 05/03/2011 01:28 PM, Jason Merrill wrote:
> stor-layout.c (copy_self_referential_tree_r): Affected by the change.
> Would you like me to add a gcc_unreachable() here?
>
> tree-inline.c (copy_tree_body_r): already copies STATEMENT_LIST itself
> (with a copy_statement_list function which I should use instead of
> open-coding it again).

Thus.  Tested x86_64-pc-linux-gnu with c,ada,c++,fortran,java,lto,objc. 
OK?  I also removed the recursion from copy_statement_list because it 
would just extra garbage STATEMENT_LISTs since they're already copied by 
the normal walk_tree.

Jason
commit 85aad99f6848bfaebbe5c794bf0a95c80e0f49cd
Author: Jason Merrill <jason@redhat.com>
Date:   Tue May 3 13:19:10 2011 -0400

    	PR c++/40975
    	* tree-inline.c (copy_tree_r): Use copy_statement_list.
    	(copy_statement_list): Don't recurse.
    	* stor-layout.c (copy_self_referential_tree_r): Don't allow
    	STATEMENT_LIST.
diff mbox

Patch

diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index ea0d44d..ecd1450 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -245,6 +245,8 @@  copy_self_referential_tree_r (tree *tp, int *walk_subtrees, void *data)
      cannot always guarantee in practice.  So punt in this case.  */
   else if (code == SAVE_EXPR)
     return error_mark_node;
+  else if (code == STATEMENT_LIST)
+    gcc_unreachable ();
 
   return copy_tree_r (tp, walk_subtrees, data);
 }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 3777675..ea7b7ab 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -662,8 +662,6 @@  copy_statement_list (tree *tp)
   for (; !tsi_end_p (oi); tsi_next (&oi))
     {
       tree stmt = tsi_stmt (oi);
-      if (TREE_CODE (stmt) == STATEMENT_LIST)
-	copy_statement_list (&stmt);
       tsi_link_after (&ni, stmt, TSI_CONTINUE_LINKING);
     }
 }
@@ -4272,19 +4270,9 @@  copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
       *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;
-    }
+    /* 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)