From a2dd7f8c0a1412852ba65b4519f6aa03a4bc2053 Mon Sep 17 00:00:00 2001 From: dodji Date: Wed, 7 Apr 2010 15:16:12 +0000 Subject: [PATCH] Fix PR c++/42697 gcc/cp/ChangeLog: PR c++/42697 *pt.c (tsubst_decl): Get the arguments of a specialization from the specialization template, not from the most general template. gcc/testsuite/ChangeLog: PR c++/42697 * g++.dg/template/crash94.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158068 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/crash94.C | 28 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/crash94.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6af8a20af12..3d412443a7b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2010-04-07 Dodji Seketeli + PR c++/42697 + *pt.c (tsubst_decl): Get the arguments of a specialization from + the specialization template, not from the most general template. + +2010-04-07 Dodji Seketeli + PR c++/40239 * typeck2.c (process_init_constructor_record): value-initialize members that are are not explicitely diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0bd55e1190c..13bb5aadf4d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9020,7 +9020,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) specialize R. */ gen_tmpl = most_general_template (DECL_TI_TEMPLATE (t)); argvec = tsubst_template_args (DECL_TI_ARGS - (DECL_TEMPLATE_RESULT (gen_tmpl)), + (DECL_TEMPLATE_RESULT + (DECL_TI_TEMPLATE (t))), args, complain, in_decl); /* Check to see if we already have this specialization. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65c9f0235e8..0032dd813b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2010-04-07 Dodji Seketeli + PR c++/42697 + * g++.dg/template/crash94.C: New test. + +2010-04-07 Dodji Seketeli + PR c++/40239 * g++.dg/init/aggr5.C: New test. * g++.dg/init/aggr5.C: New test. diff --git a/gcc/testsuite/g++.dg/template/crash94.C b/gcc/testsuite/g++.dg/template/crash94.C new file mode 100644 index 00000000000..810aed0a61c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash94.C @@ -0,0 +1,28 @@ +// Origin: PR c++/42697 +// { dg-do compile } + +template +class fparser +{ + template + void eval2(Value_t r[2]); +public: + void evaltest(); +}; + +template<> +template +void fparser::eval2(int r[2]) +{ + struct ObjType {}; +} + + +template +void fparser::evaltest + () +{ + eval2(0); +} + +template class fparser; -- 2.11.0