[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
parent 7277f72d
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.
2000-04-20 Tom Tromey <tromey@cygnus.com> 2000-04-20 Tom Tromey <tromey@cygnus.com>
* parse.y (not_accessible_p): Use member's class, not current * parse.y (not_accessible_p): Use member's class, not current
......
...@@ -79,6 +79,7 @@ extern tree stabilize_reference PARAMS ((tree)); ...@@ -79,6 +79,7 @@ extern tree stabilize_reference PARAMS ((tree));
#define METHOD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT| \ #define METHOD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT| \
ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE
#define INTERFACE_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT #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_METHOD_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
#define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL #define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL
...@@ -827,10 +828,12 @@ struct parser_ctxt { ...@@ -827,10 +828,12 @@ struct parser_ctxt {
context. */ context. */
#define INNER_ENCLOSING_SCOPE_CHECK(T) \ #define INNER_ENCLOSING_SCOPE_CHECK(T) \
(INNER_CLASS_TYPE_P ((T)) && !ANONYMOUS_CLASS_P ((T)) \ (INNER_CLASS_TYPE_P ((T)) && !ANONYMOUS_CLASS_P ((T)) \
/* We have a this and it's not the right one */ \
&& ((current_this \ && ((current_this \
/* We have a this and it's not the right one */ \
&& (DECL_CONTEXT (TYPE_NAME ((T))) \ && (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. */ \ /* We don't have a this. */ \
|| !current_this)) || !current_this))
......
...@@ -3348,7 +3348,7 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d ...@@ -3348,7 +3348,7 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d
sca = (GET_CPC_LIST () ? ACC_STATIC : 0); 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. */ within their enclosing classes. */
if (CPC_INNER_P ()) if (CPC_INNER_P ())
{ {
...@@ -3364,11 +3364,20 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d ...@@ -3364,11 +3364,20 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d
} }
} }
if (is_interface) if (is_interface)
check_modifiers ("Illegal modifier `%s' for interface declaration", {
flags, INTERFACE_MODIFIERS); if (CPC_INNER_P ())
uaaf = INTERFACE_INNER_MODIFIERS;
else
uaaf = INTERFACE_MODIFIERS;
check_modifiers ("Illegal modifier `%s' for interface declaration",
flags, uaaf);
}
else 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); flags, uaaf|sca|icaf);
return 0; return 0;
} }
...@@ -3748,7 +3757,7 @@ create_anonymous_class (location, type_name) ...@@ -3748,7 +3757,7 @@ create_anonymous_class (location, type_name)
return class; 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. */ interface's decl in pass 2. */
static tree static tree
...@@ -5390,8 +5399,32 @@ do_resolve_class (enclosing, class_type, decl, cl) ...@@ -5390,8 +5399,32 @@ do_resolve_class (enclosing, class_type, decl, cl)
/* Maybe some code here should be added to load the class or /* 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 something, at least if the class isn't an inner class and ended
being loaded from class file. FIXME. */ being loaded from class file. FIXME. */
if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl))) while (enclosing)
return new_class_decl; {
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 */ /* 1- Check for the type in single imports */
if (find_in_imports (class_type)) if (find_in_imports (class_type))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment