decl.c (java_add_stmt): Use a STATEMENT_LIST rather than a COMPOUND_EXPR.
authorAndrew Haley <aph@redhat.com>
Wed, 24 May 2006 14:27:53 +0000 (14:27 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Wed, 24 May 2006 14:27:53 +0000 (14:27 +0000)
2006-05-24  Andrew Haley  <aph@redhat.com>

        * decl.c (java_add_stmt): Use a STATEMENT_LIST rather than a
        COMPOUND_EXPR.

From-SVN: r114042

gcc/java/ChangeLog
gcc/java/decl.c

index fc6b8067e288cda2086a828af6891390945df28a..d316cc4dfcc0421c755e938709217e6927bfbda8 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-24  Andrew Haley  <aph@redhat.com>
+
+       * decl.c (java_add_stmt): Use a STATEMENT_LIST rather than a
+       COMPOUND_EXPR.
+
 2006-05-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        * lang.opt (femit-class-file): Remove VarExists.
index a16c49b7c4be8834cf1ca2ee0ec2e98dc9eca868..302df65428a77cfa56f9a3d85b27f512650730a3 100644 (file)
@@ -48,6 +48,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "tree-inline.h"
 #include "target.h"
 #include "version.h"
+#include "tree-iterator.h"
 
 #if defined (DEBUG_JAVA_BINDING_LEVELS)
 extern void indent (void);
@@ -2236,18 +2237,36 @@ add_stmt_to_compound (tree existing, tree type, tree stmt)
     return stmt;
 }
 
-/* Add a statement to the compound_expr currently being
-   constructed.  */
+/* Add a statement to the statement_list currently being constructed.
+   If the statement_list is null, we don't create a singleton list.
+   This is necessary because poplevel() assumes that adding a
+   statement to a null statement_list returns the statement.  */
 
 tree
-java_add_stmt (tree stmt)
+java_add_stmt (tree new_stmt)
 {
+  tree stmts = current_binding_level->stmts;
+  tree_stmt_iterator i;
+
   if (input_filename)
-    SET_EXPR_LOCATION (stmt, input_location);
+    SET_EXPR_LOCATION (new_stmt, input_location);
   
-  return current_binding_level->stmts 
-    = add_stmt_to_compound (current_binding_level->stmts, 
-                           TREE_TYPE (stmt), stmt);
+  if (stmts == NULL)
+    return current_binding_level->stmts = new_stmt;
+
+  /* Force STMTS to be a statement_list.  */
+  if (TREE_CODE (stmts) != STATEMENT_LIST)
+    {
+      tree t = make_node (STATEMENT_LIST);
+      i = tsi_last (t);
+      tsi_link_after (&i, stmts, TSI_CONTINUE_LINKING);
+      stmts = t;
+    }  
+      
+  i = tsi_last (stmts);
+  tsi_link_after (&i, new_stmt, TSI_CONTINUE_LINKING);
+
+  return current_binding_level->stmts = stmts;
 }
 
 /* Add a variable to the current scope.  */