aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/parse.y
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2001-05-31 06:05:29 +0000
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>2001-05-30 23:05:29 -0700
commit86d9e8d8649eed63bb456092fba7bcb5d38664bb (patch)
tree12fb4498d39e76f2172cd224ddf4b790d45dc6f7 /gcc/java/parse.y
parent9fd51e6700a8ba4db53969fffa773b22a49c1843 (diff)
downloadgcc-86d9e8d8649eed63bb456092fba7bcb5d38664bb.zip
gcc-86d9e8d8649eed63bb456092fba7bcb5d38664bb.tar.gz
gcc-86d9e8d8649eed63bb456092fba7bcb5d38664bb.tar.bz2
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
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r--gcc/java/parse.y27
1 files changed, 21 insertions, 6 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 10283b5..2b0038b 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -5522,13 +5522,14 @@ tree
do_resolve_class (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
it is changed by find_in_imports{_on_demand} and (but it doesn't
really matter) qualify_and_find */
/* 0- Search in the current class as an inner class */
+ start = enclosing;
/* 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
@@ -5551,14 +5552,28 @@ do_resolve_class (enclosing, class_type, decl, cl)
}
/* Now go to the upper classes, bail out if necessary. */
- enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
- if (!enclosing || enclosing == object_type_node)
+ super = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
+ if (!super || super == object_type_node)
break;
- if (TREE_CODE (enclosing) == POINTER_TYPE)
- enclosing = do_resolve_class (NULL, enclosing, NULL, NULL);
+ if (TREE_CODE (super) == POINTER_TYPE)
+ super = do_resolve_class (NULL, super, NULL, NULL);
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