re PR java/25429 (can't see private static final int CREATE = 1)
authorTom Tromey <tromey@redhat.com>
Fri, 16 Dec 2005 00:00:43 +0000 (00:00 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 16 Dec 2005 00:00:43 +0000 (00:00 +0000)
gcc/java:
PR java/25429
* parse.y (resolve_expression_name): Don't generate accessor
methods for constant fields.
libjava:
* testsuite/libjava.compile/rh175833.java: New file.
* testsuite/libjava.compile/pr25429.java: New file.

Co-Authored-By: Andrew Haley <aph@redhat.com>
From-SVN: r108608

gcc/java/ChangeLog
gcc/java/parse.y
libjava/ChangeLog
libjava/testsuite/libjava.compile/pr25429.java [new file with mode: 0644]
libjava/testsuite/libjava.compile/rh175833.java [new file with mode: 0644]

index 05577d5..9843b6c 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-15  Tom Tromey  <tromey@redhat.com>
+           Andrew Haley  <aph@redhat.com>
+
+       PR java/25429
+       * parse.y (resolve_expression_name): Don't generate accessor
+       methods for constant fields.
+
 2005-12-13  Andrew Haley  <aph@redhat.com>
 
        PR java/25366
index 056feea..a467ff1 100644 (file)
@@ -9584,8 +9584,15 @@ resolve_expression_name (tree id, tree *orig)
 
              /* If we're processing an inner class and we're trying
                 to access a field belonging to an outer class, build
-                the access to the field.  */
-             if (nested_member_access_p (current_class, decl))
+                the access to the field.
+                As usual, we have to treat initialized static final
+                variables as a special case.  */
+              if (nested_member_access_p (current_class, decl)
+                  && ! (JDECL_P (decl) && CLASS_FINAL_VARIABLE_P (decl)
+                        && DECL_INITIAL (decl) != NULL_TREE
+                       && (JSTRING_TYPE_P (TREE_TYPE (decl))
+                           || JNUMERIC_TYPE_P (TREE_TYPE (decl)))
+                       && TREE_CONSTANT (DECL_INITIAL (decl))))
                {
                  if (!fs && CLASS_STATIC (TYPE_NAME (current_class)))
                    {
index 0c00f2e..b3a03b7 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-15  Tom Tromey  <tromey@redhat.com>
+
+       * testsuite/libjava.compile/rh175833.java: New file.
+       * testsuite/libjava.compile/pr25429.java: New file.
+
 2005-12-15  Alan Modra  <amodra@bigpond.net.au>
 
        * testsuite/lib/libjava.exp: Revert 2005-12-01.
diff --git a/libjava/testsuite/libjava.compile/pr25429.java b/libjava/testsuite/libjava.compile/pr25429.java
new file mode 100644 (file)
index 0000000..a869b58
--- /dev/null
@@ -0,0 +1,13 @@
+public class pr25429
+{
+  private static final int CONST  = 0;
+  class I {
+    public void f () {
+      switch(0) {
+      case CONST:
+      }
+    }
+  }
+
+  public static void main(String[] args) { }
+}
diff --git a/libjava/testsuite/libjava.compile/rh175833.java b/libjava/testsuite/libjava.compile/rh175833.java
new file mode 100644 (file)
index 0000000..6bdec57
--- /dev/null
@@ -0,0 +1,13 @@
+// Follow-on to PR 25429
+public class rh175833
+{
+  private static final Object CONST  = new Object();
+    class I {
+        public Object f () {
+         // We need an accessor here.
+         return CONST;
+        }
+    }
+
+  public static void main(String[] args) { }
+}