diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2ce3f448605..27126a5b297 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-08-11 Jason Merrill + + * decl.c (lookup_name_real): Don't forget the TYPENAME_TYPE we're + looking inside. + 2000-08-11 Nathan Sidwell * cp-tree.h (resolve_scope_to_name): Remove unused prototype. @@ -882,7 +887,7 @@ Wed Jul 26 15:05:51 CEST 2000 Marc Espie * semantics.c (emit_associated_thunks): New function. (expand_body): Use it. * ir.texi: Adjust decriptions of thunks. - + 2000-06-22 Jason Merrill * pt.c (tsubst_decl, case FUNCTION_DECL): Clear DECL_SAVED_TREE. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d3a0e52bd12..e84264df391 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5898,6 +5898,13 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) { val = lookup_member (type, name, 0, prefer_type); type_access_control (type, val); + + /* Restore the containing TYPENAME_TYPE if we looked + through it before. */ + if (got_scope && got_scope != type + && val && TREE_CODE (val) == TYPE_DECL + && TREE_CODE (TREE_TYPE (val)) == TYPENAME_TYPE) + TYPE_CONTEXT (TREE_TYPE (val)) = got_scope; } } else diff --git a/gcc/testsuite/g++.old-deja/g++.ext/typename1.C b/gcc/testsuite/g++.old-deja/g++.ext/typename1.C new file mode 100644 index 00000000000..31de28fe8fe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/typename1.C @@ -0,0 +1,32 @@ +// Bug: g++ forgets about the instantiation of class1 when looking up +// class11_value, and tries to look things up in class1. + +// Special g++ Options: + +template +struct class1 { + struct class11 { + typedef ItIsInt class11_value; + }; +}; + +template +struct class3 { + int f(); +}; + +template +int class3::f() +{ + return class1::class11::class11_value(10); +} + +struct class2 { + typedef int class2_value; +}; + +int main() +{ + class3 the_class3; + the_class3.f(); +}