This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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]

[gcjx] Patch: FYI: another array initializer fix


I'm checking this in on the gcjx branch.

This fixes a remaining issue with array initializers.
We have to emit an extended COMPOUND_EXPR and not a statement
sequence, as GENERIC doesn't allow statements to appear where we were
using them.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* tree.cc (visit_array_initializer): Build COMPOUND_EXPRs, not a
	statement list.  Lay out array class.

Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 tree.cc
--- tree.cc 24 Mar 2005 02:31:33 -0000 1.1.2.21
+++ tree.cc 24 Mar 2005 15:31:15 -0000
@@ -941,17 +940,22 @@
   else
     current = build_new_object_array (elt_type->type (), ind_tree);
 
+  // Ensure array class is laid out.
+  gcc_builtins->lay_out_class (elt_type->type ()->array ());
+
   // At this point, 'current' is the 'new' expression for the array.
   tree new_expr = save_expr (current);
 
-  tree result = alloc_stmt_list ();
-  tree_stmt_iterator out = tsi_start (result);
+  // Yield 'new_expr'.
+  tree result = new_expr;
 
   tree elt_tree = gcc_builtins->map_type (elt_type->type ());
 
-  int index = 0;
-  for (std::list<ref_expression>::const_iterator i = exprs.begin ();
-       i != exprs.end ();
+  // Build in reverse order so that the result ends up on the right
+  // hand side of the last compound expression.
+  int index = exprs.size () - 1;
+  for (std::list<ref_expression>::const_reverse_iterator i = exprs.rbegin ();
+       i != exprs.rend ();
        ++i)
     {
       (*i)->visit (this);
@@ -964,13 +968,11 @@
 					 elt_tree, false),
 		  value);
       TREE_SIDE_EFFECTS (assign) = 1;
-      tsi_link_after (&out, assign, TSI_CONTINUE_LINKING);
-      ++index;
+      result = build2 (COMPOUND_EXPR, TREE_TYPE (result), assign, result);
+      --index;
     }
 
-  // Yield 'new_expr'.
-  current = build2 (COMPOUND_EXPR, TREE_TYPE (new_expr),
-		    result, new_expr);
+  current = result;
 }
 
 void


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