This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the GCJ project. See the GCJ home page for more information.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hello, Here is a little patch that *seems* to fix the problem I've reported. However I'm new to egcs/gcj hacking so I could be missing important things. So check twice my changes... :) It should correct two problems: * when flag_emit_class_files is set, patch_array_ref() doesn't modify the code field of an ARRAY_REF; it is the reason why an ARRAY_REF should be accepted as a valid argument to any plusplus-like operator. * when flag_emit_class_files is not set, and if the array index is considered to have side effects (which is the case if the index is a variable...), the ARRAY_REF is replaced by a COMPOUND_EXPR by patch_array_ref(). The patch simply moves the plusplus-like operator on the second statement of the COMPOUND_EXPR, and applies patch_unaryop recursively. Hope it can help, MoT Changelog entry: 1999-04-11 MoT le Vilain <Sebastien.Villemot@ens.fr> * parse.y (patch_unaryop): Corrected handling of array references.
Index: parse.y
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/parse.y,v
retrieving revision 1.73
diff -c -3 -p -r1.73 parse.y
*** parse.y 1999/04/09 16:26:33 1.73
--- parse.y 1999/04/11 18:57:25
*************** patch_unaryop (node, wfl_op)
*** 9741,9750 ****
case PREINCREMENT_EXPR:
/* 15.14.2 Prefix Decrement Operator -- */
case PREDECREMENT_EXPR:
decl = strip_out_static_field_access_decl (op);
if (!JDECL_P (decl)
&& !((TREE_CODE (decl) == INDIRECT_REF
! || TREE_CODE (decl) == COMPONENT_REF)
&& JPRIMITIVE_TYPE_P (TREE_TYPE (decl))))
{
tree lvalue;
--- 9741,9764 ----
case PREINCREMENT_EXPR:
/* 15.14.2 Prefix Decrement Operator -- */
case PREDECREMENT_EXPR:
+ /* For the case of an ARRAY_REF which has been expanded in a
+ COMPOUND_EXPR by patch_array_ref () */
+ if (TREE_CODE (op) == COMPOUND_EXPR)
+ {
+ tree op1 = TREE_OPERAND (op, 0);
+ tree op2 = TREE_OPERAND (op, 1);
+ op2 = patch_unaryop (build1 (code, NULL_TREE, op2), op2);
+ if (op2 == error_mark_node)
+ return error_mark_node;
+ node = build (COMPOUND_EXPR, TREE_TYPE (op2), op1, op2);
+ CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (op);
+ return node;
+ }
decl = strip_out_static_field_access_decl (op);
if (!JDECL_P (decl)
&& !((TREE_CODE (decl) == INDIRECT_REF
! || TREE_CODE (decl) == COMPONENT_REF
! || TREE_CODE (decl) == ARRAY_REF)
&& JPRIMITIVE_TYPE_P (TREE_TYPE (decl))))
{
tree lvalue;