diff options
author | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-04-21 16:03:19 -0700 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-04-21 16:03:19 -0700 |
commit | a40d21da8f16783007aa8af78f2dae948b178542 (patch) | |
tree | 405703f4d7cbd7c926b3a4860ef278bf8c5e1c67 /gcc/java/parse.y | |
parent | 7277f72df9c5ce236fbab10119e4cee60b620dc0 (diff) | |
download | gcc-a40d21da8f16783007aa8af78f2dae948b178542.zip gcc-a40d21da8f16783007aa8af78f2dae948b178542.tar.gz gcc-a40d21da8f16783007aa8af78f2dae948b178542.tar.bz2 |
[multiple changes]
Thu Apr 20 17:41:28 2000 Mo DeJong <mdejong@cygnus.com>
* parse.h (INTERFACE_INNER_MODIFIERS): New macro.
* parse.y (check_class_interface_creation): Fixed comments. Select
permitted modifiers for (inner) interfaces. Changed error message
to report rejected modifiers used with local classes.
2000-04-20 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.h (INNER_ENCLOSING_SCOPE_CHECK): Immediate inner classes
of directly inherited type considered in scope.
* parse.y (do_resolve_class): Search inherited classes for inner
classes.
(This fixes the PR #194 and #197:
http://sourceware.cygnus.com/ml/java-prs/2000-q2/msg00008.html
http://sourceware.cygnus.com/ml/java-prs/2000-q2/msg00011.html)
From-SVN: r33330
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r-- | gcc/java/parse.y | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 63ee67d..b4d3ec7 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -3348,7 +3348,7 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d sca = (GET_CPC_LIST () ? ACC_STATIC : 0); } - /* Inner classes and interfaces can be declared private or protected + /* Inner classes can be declared private or protected within their enclosing classes. */ if (CPC_INNER_P ()) { @@ -3364,11 +3364,20 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d } } - if (is_interface) - check_modifiers ("Illegal modifier `%s' for interface declaration", - flags, INTERFACE_MODIFIERS); + if (is_interface) + { + if (CPC_INNER_P ()) + uaaf = INTERFACE_INNER_MODIFIERS; + else + uaaf = INTERFACE_MODIFIERS; + + check_modifiers ("Illegal modifier `%s' for interface declaration", + flags, uaaf); + } else - check_modifiers ("Illegal modifier `%s' for class declaration", + check_modifiers ((current_function_decl ? + "Illegal modifier `%s' for local class declaration" : + "Illegal modifier `%s' for class declaration"), flags, uaaf|sca|icaf); return 0; } @@ -3748,7 +3757,7 @@ create_anonymous_class (location, type_name) return class; } -/* Create an class in pass1 and return its decl. Return class +/* Create a class in pass1 and return its decl. Return class interface's decl in pass 2. */ static tree @@ -5390,8 +5399,32 @@ do_resolve_class (enclosing, class_type, decl, cl) /* Maybe some code here should be added to load the class or something, at least if the class isn't an inner class and ended being loaded from class file. FIXME. */ - if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl))) - return new_class_decl; + while (enclosing) + { + tree name; + + if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl))) + return new_class_decl; + + /* Now go to the upper classes, bail out if necessary. */ + enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing)); + if (!enclosing || enclosing == object_type_node) + break; + + if (TREE_CODE (enclosing) == RECORD_TYPE) + { + enclosing = TYPE_NAME (enclosing); + continue; + } + + if (TREE_CODE (enclosing) == IDENTIFIER_NODE) + { + BUILD_PTR_FROM_NAME (name, enclosing); + } + else + name = enclosing; + enclosing = do_resolve_class (NULL, name, NULL, NULL); + } /* 1- Check for the type in single imports */ if (find_in_imports (class_type)) |