OSDN Git Service

2006-05-24 Andrew Haley <aph@redhat.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 May 2006 14:27:53 +0000 (14:27 +0000)
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 May 2006 14:27:53 +0000 (14:27 +0000)
        * decl.c (java_add_stmt): Use a STATEMENT_LIST rather than a
        COMPOUND_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114042 138bc75d-0d04-0410-961f-82ee72b054a4

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

index fc6b806..d316cc4 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 a16c49b..302df65 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.  */