From 0566edad11e338aa8926eb59228ac3214492eb8d Mon Sep 17 00:00:00 2001 From: bryce Date: Wed, 27 Mar 2002 08:27:27 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51438 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/java/ChangeLog | 7 +++++++ gcc/java/expr.c | 10 ---------- gcc/java/parse.y | 7 +++++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 8549fcb..8fc8e7b 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2002-03-27 Bryce McKinlay + + 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 Fix for PR java/5942: diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 2a8e2e3..a1ec332 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -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); diff --git a/gcc/java/parse.y b/gcc/java/parse.y index e8ef2ef..50ed45d 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -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; } -- 2.7.4