From 7a20d68989dac61d98b12b5d32404f04021d211f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 24 Sep 2007 16:54:34 -0400 Subject: [PATCH] re PR c++/33239 (internal compiler error in instantiate_class_template, at cp/pt.c:5666) PR c++/33239 * pt.c (resolve_typename_type): Don't look things up in the original template if it would mean losing template arguments. From-SVN: r128725 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 13 ++++++++++--- gcc/testsuite/g++.dg/template/memtmpl3.C | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/memtmpl3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5e9b1875b2e..6950166f13a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-09-24 Jason Merrill + + PR c++/33239 + * pt.c (resolve_typename_type): Don't look things up in the original + template if it would mean losing template arguments. + 2007-09-24 Jakub Jelinek PR c++/33506 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c9ec37034a5..5b07c7027a7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15732,9 +15732,16 @@ resolve_typename_type (tree type, bool only_current_p) to look inside it. */ if (only_current_p && !currently_open_class (scope)) return type; - /* If SCOPE is a partial instantiation, it will not have a valid - TYPE_FIELDS list, so use the original template. */ - scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope); + /* If SCOPE isn't the template itself, it will not have a valid + TYPE_FIELDS list. */ + if (same_type_p (scope, CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope))) + /* scope is either the template itself or a compatible instantiation + like X, so look up the name in the original template. */ + scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope); + else + /* scope is a partial instantiation, so we can't do the lookup or we + will lose the template arguments. */ + return type; /* Enter the SCOPE so that name lookup will be resolved as if we were in the class definition. In particular, SCOPE will no longer be considered a dependent type. */ diff --git a/gcc/testsuite/g++.dg/template/memtmpl3.C b/gcc/testsuite/g++.dg/template/memtmpl3.C new file mode 100644 index 00000000000..583155ea760 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/memtmpl3.C @@ -0,0 +1,24 @@ +// PR c++/33239 + +struct null_type; + +template +struct tuple_impl +{ + template + struct append + { + typedef tuple_impl type; + }; + + int data; +}; + +template +class tuple +: public tuple_impl::template append::type +{ + using tuple_impl::template append::type::data; +}; + +tuple my_tuple; -- 2.30.2