[PATCH]: Java fix for the PRs 194, 197.
Alexandre Petit-Bianco
apbianco@cygnus.com
Fri Apr 21 16:03:00 GMT 2000
I'm committing the following patch which 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
./A
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.
Index: parse.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
retrieving revision 1.49
diff -u -p -r1.49 parse.h
--- parse.h 2000/04/06 00:43:27 1.49
+++ parse.h 2000/04/21 22:56:25
@@ -79,6 +79,7 @@ extern tree stabilize_reference PARAMS (
#define METHOD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT| \
ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE
#define INTERFACE_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
+#define INTERFACE_INNER_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT|ACC_STATIC
#define INTERFACE_METHOD_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
#define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL
@@ -827,10 +828,12 @@ struct parser_ctxt {
context. */
#define INNER_ENCLOSING_SCOPE_CHECK(T) \
(INNER_CLASS_TYPE_P ((T)) && !ANONYMOUS_CLASS_P ((T)) \
- /* We have a this and it's not the right one */ \
&& ((current_this \
+ /* We have a this and it's not the right one */ \
&& (DECL_CONTEXT (TYPE_NAME ((T))) \
- != TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))) \
+ != TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this)))) \
+ && !inherits_from_p (TREE_TYPE (TREE_TYPE (current_this)), \
+ TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))) \
/* We don't have a this. */ \
|| !current_this))
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.153
diff -u -p -r1.153 parse.y
--- parse.y 2000/04/21 19:53:15 1.153
+++ parse.y 2000/04/21 22:56:59
@@ -3348,7 +3348,7 @@ check_class_interface_creation (is_inter
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_inter
}
}
- 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_n
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,
/* 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))
More information about the Gcc-patches
mailing list