Patch: gcj: fix for PR gcj/140
Tom Tromey
tromey@cygnus.com
Wed Apr 5 22:18:00 GMT 2000
Alex suggested a change to my fix for PR gcj/140.
I've made this fix, and I'm checking in the appended patch.
2000-04-05 Tom Tromey <tromey@cygnus.com>
Fix for PR gcj/140:
* parse.y (check_final_assignment): Recognize assignments to the
`length' field of an array when generating class files.
Tom
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.149
diff -u -r1.149 parse.y
--- parse.y 2000/04/06 00:43:27 1.149
+++ parse.y 2000/04/06 05:16:09
@@ -11421,10 +11421,16 @@
&& JDECL_P (TREE_OPERAND (lvalue, 1)))
lvalue = TREE_OPERAND (lvalue, 1);
- if (TREE_CODE (lvalue) == FIELD_DECL
- && FIELD_FINAL (lvalue)
- && !DECL_CLINIT_P (current_function_decl)
- && !DECL_FINIT_P (current_function_decl))
+ /* When generating class files, references to the `length' field
+ look a bit different. */
+ if ((flag_emit_class_files
+ && TREE_CODE (lvalue) == COMPONENT_REF
+ && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
+ && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
+ || (TREE_CODE (lvalue) == FIELD_DECL
+ && FIELD_FINAL (lvalue)
+ && !DECL_CLINIT_P (current_function_decl)
+ && !DECL_FINIT_P (current_function_decl)))
{
parse_error_context
(wfl, "Can't assign a value to the final variable `%s'",
More information about the Gcc-patches
mailing list