aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/parse.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-04-06 05:29:30 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-04-06 05:29:30 +0000
commitbc2874c902997772cb649232f182d4908605a7ee (patch)
tree8562ab0fc47554522b3e62608f787262ecf77eae /gcc/java/parse.c
parent16d53b6439684014a67dd9086e8e75e26f6ee4ec (diff)
downloadgcc-bc2874c902997772cb649232f182d4908605a7ee.zip
gcc-bc2874c902997772cb649232f182d4908605a7ee.tar.gz
gcc-bc2874c902997772cb649232f182d4908605a7ee.tar.bz2
re GNATS gcj/140 (gcj permits assignment to array length)
Fix for PR gcj/140: * parse.y (check_final_assignment): Recognize assignments to the `length' field of an array when generating class files. From-SVN: r32960
Diffstat (limited to 'gcc/java/parse.c')
-rw-r--r--gcc/java/parse.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/java/parse.c b/gcc/java/parse.c
index e15e571..f65e21f 100644
--- a/gcc/java/parse.c
+++ b/gcc/java/parse.c
@@ -14053,10 +14053,16 @@ check_final_assignment (lvalue, wfl)
&& 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'",