re GNATS gcj/140 (gcj permits assignment to array length)
authorTom Tromey <tromey@cygnus.com>
Thu, 6 Apr 2000 05:29:30 +0000 (05:29 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 6 Apr 2000 05:29:30 +0000 (05:29 +0000)
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

gcc/java/ChangeLog
gcc/java/parse.c
gcc/java/parse.y

index 63c7f08bfbdf09e7baf7f8a36701c1086f56acc6..8123c230f75853ec3131ca8521a371da90d39180 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2000-04-05  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
        * class.c (decl_hash): Prototype removed.
index e15e571820423f673c18c8164032822d825ae93d..f65e21fccf13d23ee66464445a08361e0ce6586d 100644 (file)
@@ -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'",
index cac9a3a9121e2e1d80fda8afd62d7cfb01c0892e..17e74c2dd598a49087324e2e4ac40ec4eb076136 100644 (file)
@@ -11421,10 +11421,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'",