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: fix multi-dimensional 'new'


I'm checking this in on the gcjx branch.

This fixes 'new' of a multi-dimensional array.  We were missing some
arguments.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* tree.cc (visit_new_array): Correctly handle multi-dimensional
	case.

Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.59
diff -u -r1.1.2.59 tree.cc
--- tree.cc 11 Oct 2005 00:49:32 -0000 1.1.2.59
+++ tree.cc 11 Oct 2005 01:24:18 -0000
@@ -2271,6 +2271,7 @@
     }
   else if (indices.size () != 0)
     {
+      int num = 0;
       tree args = NULL_TREE;
       for (std::list<ref_expression>::const_iterator i = indices.begin ();
 	   i != indices.end ();
@@ -2278,12 +2279,21 @@
 	{
 	  (*i)->visit (this);
 	  args = tree_cons (NULL_TREE, current, args);
+	  ++num;
 	}
+      // We constructed the dimension arguments in reverse order.
+      args = nreverse (args);
+
+      args = tree_cons (NULL_TREE, build_int (num), args);
+      args = tree_cons (NULL_TREE,
+			build_class_ref (new_elt->type (), new_elt),
+			args);
 
       tree array_type_tree = gcc_builtins->map_type (new_elt->type ());
-      current = build3 (CALL_EXPR, array_type_tree,
-			builtin_Jv_NewMultiArray,
-			nreverse (args), NULL_TREE);
+      current = convert (array_type_tree,
+			 build3 (CALL_EXPR, ptr_type_node,
+				 builtin_Jv_NewMultiArray,
+				 args, NULL_TREE));
       annotate (current, new_elt);
     }
   else


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