This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java: fix for the PR #122
- To: egcs-patches at egcs dot cygnus dot com
- Subject: [PATCH] Java: fix for the PR #122
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Fri, 7 Jan 2000 12:30:06 -0800
I checked in the following patch which fixes the Java PR #122:
http://sourceware.cygnus.com/ml/java-prs/2000-q1/msg00000.html
./A
Thu Jan 6 00:54:10 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
* jcf-write.c (generate_byecode_conditional): Fixed indentation in
method invocation and typo in conditional expression.
(generate_bytecode_insns): COND_EXPR can be part of a binop. Issue
the appropriate NOTE_POP.
* parse.y (patch_binop): Shift value mask to feature the right
type.
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-write.c,v
retrieving revision 1.40
diff -u -p -r1.40 jcf-write.c
--- jcf-write.c 1999/12/10 16:06:23 1.40
+++ jcf-write.c 2000/01/06 08:52:17
@@ -1160,7 +1160,8 @@ generate_bytecode_conditional (exp, true
}
break;
case TRUTH_NOT_EXPR:
- generate_bytecode_conditional (TREE_OPERAND (exp, 0), false_label, true_label,
+ generate_bytecode_conditional (TREE_OPERAND (exp, 0),
+ false_label, true_label,
! true_branch_first, state);
break;
case TRUTH_ANDIF_EXPR:
@@ -1238,7 +1239,7 @@ generate_bytecode_conditional (exp, true
}
if (integer_zerop (exp1) || integer_zerop (exp0))
{
- generate_bytecode_insns (integer_zerop (exp1) ? exp0 : exp0,
+ generate_bytecode_insns (integer_zerop (exp1) ? exp0 : exp1,
STACK_TARGET, state);
op = op + (OPCODE_ifnull - OPCODE_if_acmpeq);
negop = (op & 1) ? op - 1 : op + 1;
@@ -1622,6 +1623,10 @@ generate_bytecode_insns (exp, target, st
define_jcf_label (else_label, state);
generate_bytecode_insns (TREE_OPERAND (exp, 2), target, state);
define_jcf_label (end_label, state);
+
+ /* COND_EXPR can be used in a binop. The stack must be adjusted. */
+ if (TREE_TYPE (exp) != void_type_node)
+ NOTE_POP (TYPE_PRECISION (TREE_TYPE (exp)) > 32 ? 2 : 1);
}
break;
case CASE_EXPR:
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.126
diff -u -p -r1.126 parse.y
--- parse.y 1999/12/31 03:30:21 1.126
+++ parse.y 2000/01/06 08:52:44
@@ -9814,13 +9814,11 @@ patch_binop (node, wfl_op1, wfl_op2)
type of the left-hand operand */
prom_type = TREE_TYPE (op1);
- /* Shift int only up to 0x1f and long up to 0x3f */
- if (prom_type == int_type_node)
- op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
- build_int_2 (0x1f, 0)));
- else
- op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
- build_int_2 (0x3f, 0)));
+ /* Shift int only up to 0x1f and long up to 0x3f. The bytecode
+ generator should take care of removing this operation. FIXME */
+ op2 = fold (build (BIT_AND_EXPR, prom_type, convert (prom_type, op2),
+ (prom_type == int_type_node ? build_int_2 (0x1f, 0) :
+ convert (prom_type, build_int_2 (0x3f, 0)))));
/* The >>> operator is a >> operating on unsigned quantities */
if (code == URSHIFT_EXPR && ! flag_emit_class_files)