This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: PR java/8676
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 22 Nov 2002 09:50:34 -0700
- Subject: Patch: PR java/8676
- Reply-to: tromey at redhat dot com
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);