From: Kriang Lerdsuwanakij Date: Sat, 31 May 2003 12:13:30 +0000 (+0000) Subject: re PR c++/10956 (ICE when specializing a template member function of a template class... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76d3baad59795d627f537ea623b0f0e654c3865a;p=gcc.git re PR c++/10956 (ICE when specializing a template member function of a template class, in tsubst, at cp/pt.c:6459) PR c++/10956 * pt.c (instantiate_decl): Don't use full template arguments if we are dealing with specializations. * g++.dg/template/spec9.C: New test. From-SVN: r67268 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3071e2b567b..33ae807984b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-05-31 Kriang Lerdsuwanakij + + PR c++/10956 + * pt.c (instantiate_decl): Don't use full template arguments if + we are dealing with specializations. + 2003-05-29 Gabriel Dos Reis * decl.c (ENABLE_SCOPE_CHECKING): Rename from DEBUG_BINDING_LEVELS. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f775346b163..2e163c840a9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10862,10 +10862,11 @@ instantiate_decl (d, defer_ok) td = template_for_substitution (d); code_pattern = DECL_TEMPLATE_RESULT (td); - if (DECL_NAMESPACE_SCOPE_P (d) && !DECL_INITIALIZED_IN_CLASS_P (d)) + if ((DECL_NAMESPACE_SCOPE_P (d) && !DECL_INITIALIZED_IN_CLASS_P (d)) + || DECL_TEMPLATE_SPECIALIZATION (td)) /* In the case of a friend template whose definition is provided outside the class, we may have too many arguments. Drop the - ones we don't need. */ + ones we don't need. The same is true for specializations. */ args = get_innermost_template_args (gen_args, TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (td))); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e61b1486098..628551e7948 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-05-31 Kriang Lerdsuwanakij + + PR c++/10956 + * g++.dg/template/spec9.C: New test. + 2003-05-29 Roger Sayle * gcc.dg/duff-4.c: New test case. diff --git a/gcc/testsuite/g++.dg/template/spec9.C b/gcc/testsuite/g++.dg/template/spec9.C new file mode 100644 index 00000000000..013fa0d9920 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec9.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +// Origin: Lynn Akers +// Wolfgang Bangerth + +// PR c++/10956: Incorrect template substitution for member template +// specialization inside template class. + +template struct C { + template void pre_add(T); +}; + +template<> +template +void C<32>::pre_add(T) { + T pre; +} + +int main() { + C<32>().pre_add(1); +}