This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Use a STATEMENT_LIST rather than a COMPOUND_EXPR


With recent gcc we're blowing up in unshare because the use of
COMPOUND_EXPRs in Java leads to very deep recursion.  

The easisest thing seems to be to use a STATEMENT_LIST rather than a
COMPOUND_EXPR.

Andrew.


2006-05-24  Andrew Haley  <aph@redhat.com>

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

Index: gcc/java/decl.c
===================================================================
*** gcc/java/decl.c     (revision 113722)
--- gcc/java/decl.c     (working copy)
***************
*** 49,52 ****
--- 49,53 ----
  #include "target.h"
  #include "version.h"
+ #include "tree-iterator.h"
  
  #if defined (DEBUG_JAVA_BINDING_LEVELS)
***************
*** 2237,2252 ****
  }
  
! /* Add a statement to the compound_expr currently being
!    constructed.  */
  
  tree
! java_add_stmt (tree stmt)
  {
    if (input_filename)
!     SET_EXPR_LOCATION (stmt, input_location);
    
!   return current_binding_level->stmts 
!     = add_stmt_to_compound (current_binding_level->stmts, 
!                           TREE_TYPE (stmt), stmt);
  }
  
--- 2238,2271 ----
  }
  
! /* 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 new_stmt)
  {
+   tree stmts = current_binding_level->stmts;
+   tree_stmt_iterator i;
+ 
    if (input_filename)
!     SET_EXPR_LOCATION (new_stmt, input_location);
    
!   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;
  }
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]