diff options
author | apbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-02 17:58:05 +0000 |
---|---|---|
committer | apbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-02 17:58:05 +0000 |
commit | 5bf824e30e8611de9b1ef2cbf9a2f5ce64cde46e (patch) | |
tree | fb4b01019fd8d7005ba7344b0bc91da071cdedb9 /gcc/java | |
parent | 484c1e8df39bc80d8aa1664a297cf5c6158f00ca (diff) | |
download | gcc-5bf824e30e8611de9b1ef2cbf9a2f5ce64cde46e.tar.gz |
2002-02-28 Alexandre Petit-Bianco <apbianco@redhat.com>
Fix for PR java/5758, java/5632:
* jcf-parse.c (load_class): Renamed local variable, consider `.' an
inner-class separator too.
* parse.y (do_resolve_class): New local `decl_result.'
Progressively build a name for what can have been loaded.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50228 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 14 | ||||
-rw-r--r-- | gcc/java/parse.y | 28 |
3 files changed, 41 insertions, 9 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 9c0219bda56..57ad8d4ce77 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -2,6 +2,14 @@ * expr.c (build_java_arraystore_check): Fix formatting. +2002-02-28 Alexandre Petit-Bianco <apbianco@redhat.com> + + Fix for PR java/5758, java/5632: + * jcf-parse.c (load_class): Renamed local variable, consider `.' an + inner-class separator too. + * parse.y (do_resolve_class): New local `decl_result.' + Progressively build a name for what can have been loaded. + 2002-02-28 Bryce McKinlay <bryce@waitaki.otago.ac.nz> * expr.c (java_array_data_offset): Removed function. diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index e85b5781f83..484f79ce7a8 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -669,20 +669,20 @@ load_class (class_or_name, verbose) saved = name; while (1) { - char *dollar; + char *separator; if ((class_loaded = read_class (name))) break; /* We failed loading name. Now consider that we might be looking - for a inner class but it's only available in source for in - its enclosing context. */ - if ((dollar = strrchr (IDENTIFIER_POINTER (name), '$'))) + for a inner class. */ + if ((separator = strrchr (IDENTIFIER_POINTER (name), '$')) + || (separator = strrchr (IDENTIFIER_POINTER (name), '.'))) { - int c = *dollar; - *dollar = '\0'; + int c = *separator; + *separator = '\0'; name = get_identifier (IDENTIFIER_POINTER (name)); - *dollar = c; + *separator = c; } /* Otherwise, we failed, we bail. */ else diff --git a/gcc/java/parse.y b/gcc/java/parse.y index d005b4e8f96..0b5be0921ea 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -5745,6 +5745,7 @@ do_resolve_class (enclosing, class_type, decl, cl) { tree new_class_decl = NULL_TREE, super = NULL_TREE; tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE; + tree decl_result; struct hash_table _ht, *circularity_hash = &_ht; /* This hash table is used to register the classes we're going @@ -5841,9 +5842,32 @@ do_resolve_class (enclosing, class_type, decl, cl) if (check_pkg_class_access (TYPE_NAME (class_type), cl, true)) return NULL_TREE; } - + /* 6- Last call for a resolution */ - return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); + decl_result = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); + + /* The final lookup might have registered a.b.c into a.b$c If we + failed at the first lookup, progressively change the name if + applicable and use the matching DECL instead. */ + if (!decl_result && QUALIFIED_P (TYPE_NAME (class_type))) + { + tree name = TYPE_NAME (class_type); + char *separator; + do { + + /* Reach the last '.', and if applicable, replace it by a `$' and + see if this exists as a type. */ + if ((separator = strrchr (IDENTIFIER_POINTER (name), '.'))) + { + int c = *separator; + *separator = '$'; + name = get_identifier (IDENTIFIER_POINTER (name)); + *separator = c; + decl_result = IDENTIFIER_CLASS_VALUE (name); + } + } while (!decl_result && separator); + } + return decl_result; } static tree |