Commit 86d9e8d8 by Bryce McKinlay Committed by Alexandre Petit-Bianco

parse.y (do_resolve_class): Check for cyclic inheritance during inner class resolution.

2001-04-27  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>

	* parse.y (do_resolve_class): Check for cyclic inheritance during
	inner class resolution.

(http://gcc.gnu.org/ml/gcc-patches/2001-04/msg01330.html)

From-SVN: r42737
parent 9fd51e67
...@@ -100,6 +100,11 @@ ...@@ -100,6 +100,11 @@
* verify.c (verify_jvm_instructions): Initialize variable. * verify.c (verify_jvm_instructions): Initialize variable.
2001-04-27 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* parse.y (do_resolve_class): Check for cyclic inheritance during
inner class resolution.
2001-04-27 Per Bothner <per@bothner.com> 2001-04-27 Per Bothner <per@bothner.com>
* parse.y (java_expand_classes): Don't change ctxp_for_generation * parse.y (java_expand_classes): Don't change ctxp_for_generation
......
...@@ -5522,13 +5522,14 @@ tree ...@@ -5522,13 +5522,14 @@ tree
do_resolve_class (enclosing, class_type, decl, cl) do_resolve_class (enclosing, class_type, decl, cl)
tree enclosing, class_type, decl, cl; tree enclosing, class_type, decl, cl;
{ {
tree new_class_decl; tree new_class_decl, super, start;
/* Do not try to replace TYPE_NAME (class_type) by a variable, since /* Do not try to replace TYPE_NAME (class_type) by a variable, since
it is changed by find_in_imports{_on_demand} and (but it doesn't it is changed by find_in_imports{_on_demand} and (but it doesn't
really matter) qualify_and_find */ really matter) qualify_and_find */
/* 0- Search in the current class as an inner class */ /* 0- Search in the current class as an inner class */
start = enclosing;
/* 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
...@@ -5551,14 +5552,28 @@ do_resolve_class (enclosing, class_type, decl, cl) ...@@ -5551,14 +5552,28 @@ do_resolve_class (enclosing, class_type, decl, cl)
} }
/* Now go to the upper classes, bail out if necessary. */ /* Now go to the upper classes, bail out if necessary. */
enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing)); super = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
if (!enclosing || enclosing == object_type_node) if (!super || super == object_type_node)
break; break;
if (TREE_CODE (enclosing) == POINTER_TYPE) if (TREE_CODE (super) == POINTER_TYPE)
enclosing = do_resolve_class (NULL, enclosing, NULL, NULL); super = do_resolve_class (NULL, super, NULL, NULL);
else else
enclosing = TYPE_NAME (enclosing); super = TYPE_NAME (super);
/* We may not have checked for circular inheritance yet, so do so
here to prevent an infinite loop. */
if (super == start)
{
if (!cl)
cl = lookup_cl (decl);
parse_error_context
(cl, "Cyclic inheritance involving %s",
IDENTIFIER_POINTER (DECL_NAME (enclosing)));
break;
}
enclosing = super;
} }
/* 1- Check for the type in single imports. This will change /* 1- Check for the type in single imports. This will change
......
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