Patch: PR java/8676

Tom Tromey tromey@redhat.com
Fri Nov 22 08:51:00 GMT 2002


This patch fixes PR java/8676.

If the right hand side of a shift expression has type long, we must
cast it to int.  Otherwise the tree we generate confuses the bytecode
generator.

Tested on x86 Red Hat Linux 7.3.

Ok?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* parse.y (patch_binop): Cast right hand side of shift expression
	to `int'.  Fixes PR java/8676.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.402
diff -u -r1.402 parse.y
--- parse.y 18 Nov 2002 18:13:36 -0000 1.402
+++ parse.y 22 Nov 2002 06:01:46 -0000
@@ -13465,6 +13465,11 @@
       op1 = do_unary_numeric_promotion (op1);
       op2 = do_unary_numeric_promotion (op2);
 
+      /* If the right hand side is of type `long', first cast it to
+	 `int'.  */
+      if (TREE_TYPE (op2) == long_type_node)
+	op2 = build1 (CONVERT_EXPR, int_type_node, op2);
+
       /* The type of the shift expression is the type of the promoted
          type of the left-hand operand */
       prom_type = TREE_TYPE (op1);



More information about the Java-patches mailing list