diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 675aca54e272..7d02bb5b1e65 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-21 Jason Merrill + + PR c++/33959 + * pt.c (tsubst_aggr_type): Make sure our context is complete. + 2008-01-02 Volker Reichelt Backport: diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a837ba2076dc..9a6f2fc9cc69 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6325,8 +6325,13 @@ tsubst_aggr_type (tree t, up. */ context = TYPE_CONTEXT (t); if (context) - context = tsubst_aggr_type (context, args, complain, - in_decl, /*entering_scope=*/1); + { + context = tsubst_aggr_type (context, args, complain, + in_decl, /*entering_scope=*/1); + /* If context is a nested class inside a class template, + it may still need to be instantiated (c++/33959). */ + complete_type (context); + } /* Then, figure out what arguments are appropriate for the type we are trying to find. For example, given: diff --git a/gcc/testsuite/g++.dg/template/nested5.C b/gcc/testsuite/g++.dg/template/nested5.C new file mode 100644 index 000000000000..3850fdace3a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nested5.C @@ -0,0 +1,19 @@ +// PR c++/33959 + +template struct A +{ + struct C + { + template struct D {}; + }; + template static C::D bar (S const &); +}; + +struct E {}; + +int +main () +{ + E e; + A::bar (e); +}