re PR java/16701 (Error when constant initializer depends on another constant with...
authorBryce McKinlay <mckinlay@redhat.com>
Mon, 2 Aug 2004 21:20:46 +0000 (21:20 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Mon, 2 Aug 2004 21:20:46 +0000 (22:20 +0100)
2004-08-02  Bryce McKinlay  <mckinlay@redhat.com>

PR java/16701
* parse.y (fold_constant_for_init): Call resolve_field_access with
correct current_class context.

2004-08-02  Bryce McKinlay  <mckinlay@redhat.com>

* testsuite/libjava.compile/PR16701.java: New test.

From-SVN: r85453

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

index b2c0a625fa6afdf77df5451ec389604a951a5646..1cd9315f14b9191eed248a57a79efd7752084faf 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-02  Bryce McKinlay  <mckinlay@redhat.com>
+
+       PR java/16701
+       * parse.y (fold_constant_for_init): Call resolve_field_access with
+       correct current_class context.
+
 2004-08-01  Roger Sayle  <roger@eyesopen.com>
 
        * decl.c (update_aliases, initialize_local_variable): Replace calls
index c251f2f12b705d6b3b845e936933cd235a1997f6..fdff74676498a5ee8ee7136ed7a041583ccea14d 100644 (file)
@@ -15970,16 +15970,16 @@ fold_constant_for_init (tree node, tree context)
            }
          else
            {
-             /* Install the proper context for the field resolution.
-                The prior context is restored once the name is
-                properly qualified. */
+             tree r = NULL_TREE;
+             /* Install the proper context for the field resolution.  */
              tree saved_current_class = current_class;
              /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
              current_class = DECL_CONTEXT (context);
              qualify_ambiguous_name (node);
+             r = resolve_field_access (node, &decl, NULL);
+             /* Restore prior context.  */
              current_class = saved_current_class;
-             if (resolve_field_access (node, &decl, NULL)
-                 && decl != NULL_TREE)
+             if (r != error_mark_node && decl != NULL_TREE)
                return fold_constant_for_init (decl, decl);
              return NULL_TREE;
            }
index 28973292b3636399b27731f8795c2a27b431f02d..81922f2655cdd74a119ee8d3d02f48ffe0fc2ed8 100644 (file)
@@ -1,3 +1,7 @@
+2004-08-02  Bryce McKinlay  <mckinlay@redhat.com>
+
+       * testsuite/libjava.compile/PR16701.java: New test.
+
 2004-08-01  Andrew John Hughes  <gnu_andrew@member.fsf.org>
 
        * java/util/Collection.java, java/util/List.java,
diff --git a/libjava/testsuite/libjava.compile/PR16701.java b/libjava/testsuite/libjava.compile/PR16701.java
new file mode 100644 (file)
index 0000000..60d459a
--- /dev/null
@@ -0,0 +1,10 @@
+class Cl
+{
+  private static final int CONSTANT1 = 0x001;
+  public static final int CONSTANT2 = 0x002 >> CONSTANT1;
+}
+
+public class PR16701
+{
+  public static final int VALUE = Cl.CONSTANT2;
+}