This is the mail archive of the gcc-patches@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]

PR java/19907: Incorrect code generated for ManifestElement.java


This testcase first allocates a local slot as a boolean and then tries
to re-use the same slot as an integer.  The confusion is casued by the
fact that in the Java VM, stack slots for booleans and integers have
the same type.  So, when an operation returns a boolean, we should
store it in a local of int type.  This only applies to the bytecode
compiler.

This patch changes local variable allocation so that temporaries for
values of type boolean are always stored in slots of type int.

Andrew.


2005-02-11  Andrew Haley  <aph@redhat.com>

	PR java/19907
	* decl.c (find_local_variable): Promote all boolean types to int
	when searching for local variable decls.
	
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.207
diff -p -2 -c -r1.207 decl.c
*** decl.c	24 Jan 2005 19:07:06 -0000	1.207
--- decl.c	11 Feb 2005 16:44:37 -0000
*************** find_local_variable (int index, tree typ
*** 302,305 ****
--- 302,314 ----
    tree decl = NULL_TREE;
  
+   /* gcj has a function called promote_type(), which is used by both
+      the bytecode compiler and the source compiler.  Unfortunately,
+      the type systems for the Java VM and the Java language are not
+      the same: a boolean in the VM promotes to an int, not to a wide
+      boolean.  If our caller wants something to hold a boolean, that
+      had better be an int.  */
+   if (TREE_CODE (type) == BOOLEAN_TYPE)
+     type = integer_type_node;
+ 
    /* Scan through every declaration that has been created in this
       slot.  We're only looking for variables that correspond to local


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