From 28ba38e39f1fd80713c0c4bb2d5d9cd8b0d4ad0d Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Sat, 14 Feb 2004 11:29:01 +0000 Subject: [PATCH] re PR c++/13635 (ICE in register_specialization for specific order of template specialization) PR c++/13635 * pt.c (push_template_decl_real): Make sure DECL_TI_ARGS of DECL has full set of arguments. * g++.dg/template/spec11.C: New test. From-SVN: r77796 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 9 ++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/spec11.C | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/spec11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 64018adbef6..9117cdf6cd6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-02-14 Kriang Lerdsuwanakij + + PR c++/13635 + * pt.c (push_template_decl_real): Make sure DECL_TI_ARGS of DECL + has full set of arguments. + 2004-02-13 Giovanni Bajo PR c++/13927 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 085fdbd8160..779347b0f53 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1035,7 +1035,7 @@ register_specialization (tree spec, tree tmpl, tree args) the default argument expression is not substituted for in an instantiation unless and until it is actually needed. */ return spec; - + /* There should be as many levels of arguments as there are levels of parameters. */ my_friendly_assert (TMPL_ARGS_DEPTH (args) @@ -3001,6 +3001,13 @@ push_template_decl_real (tree decl, int is_friend) } } + /* The DECL_TI_ARGS of DECL contains full set of arguments refering + back to its most general template. If TMPL is a specialization, + ARGS may only have the innermost set of arguments. Add the missing + argument levels if necessary. */ + if (DECL_TEMPLATE_INFO (tmpl)) + args = add_outermost_template_args (DECL_TI_ARGS (tmpl), args); + info = tree_cons (tmpl, args, NULL_TREE); if (DECL_IMPLICIT_TYPEDEF_P (decl)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b294918147..e0ff48e75c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-02-14 Kriang Lerdsuwanakij + + PR c++/13635 + * g++.dg/template/spec11.C: New test. + 2004-02-13 Giovanni Bajo PR c++/13927 diff --git a/gcc/testsuite/g++.dg/template/spec11.C b/gcc/testsuite/g++.dg/template/spec11.C new file mode 100644 index 00000000000..36d93a94ee1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec11.C @@ -0,0 +1,20 @@ +// { dg-do compile } + +// Origin: jhbrown@bluefinrobotics.com + +// PR c++/13635: ICE explicit specialization of member function template + +template +class bar { +public: + template + int func(baz *x); +}; + +template <> +template +int bar::func(baz *x) { return 5;} + +template <> +template <> +int bar::func(int *x) { return 5;} -- 2.30.2