re PR java/5850 (resolving inherited member variables with same name works poorly)
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>
Wed, 27 Mar 2002 08:27:27 +0000 (08:27 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Wed, 27 Mar 2002 08:27:27 +0000 (08:27 +0000)
        Fix for PR java/5850:
        * parse.y (lookup_field_wrapper): Call itself recursively for enclosing
        context if field was not found in the current scope.
        * expr.c (lookup_field): Don't look in enclosing contexts.

From-SVN: r51438

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

index 8549fcb4a7f52e803de26d6fe576b2ea7e08bad4..8fc8e7b1b0454a27feb9084c162c22d7ff01f14f 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-27  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
+
+       Fix for PR java/5850:
+       * parse.y (lookup_field_wrapper): Call itself recursively for enclosing
+       context if field was not found in the current scope.
+       * expr.c (lookup_field): Don't look in enclosing contexts.
+
 2002-03-26  Tom Tromey  <tromey@redhat.com>
 
        Fix for PR java/5942:
index 2a8e2e3d85c1f32d736bba6b3bc3e4abd65d00a7..a1ec3320e2aac8f644d35096caa0599231093409 100644 (file)
@@ -1517,16 +1517,6 @@ lookup_field (typep, name)
        if (DECL_NAME (field) == name)
          return field;
 
-      /* If *typep is an innerclass, lookup the field in its enclosing
-         contexts */
-      if (INNER_CLASS_TYPE_P (*typep))
-       {
-         tree outer_type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (*typep)));
-
-         if ((field = lookup_field (&outer_type, name)))
-           return field;
-       }
-
       /* Process implemented interfaces. */
       basetype_vec = TYPE_BINFO_BASETYPES (*typep);
       n = TREE_VEC_LENGTH (basetype_vec);
index e8ef2ef6b2b1a117dbd15a62154b5a219349b4d6..50ed45d4bad834ac0f94f89fb4079edece8581a2 100644 (file)
@@ -4209,6 +4209,13 @@ lookup_field_wrapper (class, name)
       decl = lookup_field (&type, name);
     }
 
+  /* If the field still hasn't been found, try the next enclosing context. */
+  if (!decl && INNER_CLASS_TYPE_P (class))
+    {
+      tree outer_type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
+      decl = lookup_field_wrapper (outer_type, name);
+    }
+
   java_parser_context_restore_global ();
   return decl == error_mark_node ? NULL : decl;
 }