re PR java/19277 (allows array.length++ although it is final)
authorRanjit Mathew <rmathew@hotmail.com>
Mon, 10 Jan 2005 18:01:04 +0000 (18:01 +0000)
committerRanjit Mathew <rmathew@gcc.gnu.org>
Mon, 10 Jan 2005 18:01:04 +0000 (18:01 +0000)
        PR java/19277
        * check-init.c (check_init): Take care of references that do not
        have an explicit final variable declaration (e.g. array length
        access) for pre/post in/de-crement operators.

From-SVN: r93144

gcc/java/ChangeLog
gcc/java/check-init.c

index af1736dc96a41ac48e20961a11bca96f658ecc9a..183319ff325a9d9f3112a2d60d997c740ae18aa8 100644 (file)
@@ -1,3 +1,10 @@
+2005-01-10  Ranjit Mathew  <rmathew@hotmail.com>
+
+       PR java/19277
+       * check-init.c (check_init): Take care of references that do not
+       have an explicit final variable declaration (e.g. array length
+       access) for pre/post in/de-crement operators.
+
 2005-01-08  Mark Wielaard  <mark@klomp.org>
 
        * parse.y (process_imports): Allocate (and free) original_name only
index e124ffc5eefc01a8dd5b1d6a3c2cead7dcf64145..6dc0deee7fdc8e45b4f5280b9858d21c34766707 100644 (file)
@@ -1,5 +1,6 @@
 /* Code to test for "definitive [un]assignment".
-   Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation,
+   Inc.
 
 This file is part of GCC.
 
@@ -832,7 +833,14 @@ check_init (tree exp, words before)
     case POSTINCREMENT_EXPR:
       tmp = get_variable_decl (TREE_OPERAND (exp, 0));
       if (tmp != NULL_TREE && DECL_FINAL (tmp))
-       final_assign_error (DECL_NAME (tmp));      
+       final_assign_error (DECL_NAME (tmp));
+      else if (TREE_CODE (tmp = TREE_OPERAND (exp, 0)) == COMPONENT_REF)
+        {
+          /* Take care of array length accesses too.  */
+          tree decl = TREE_OPERAND (tmp, 1);
+          if (DECL_FINAL (decl))
+            final_assign_error (DECL_NAME (decl));
+        }
 
       /* Avoid needless recursion.  */
       exp = TREE_OPERAND (exp, 0);