From 2865105751562a5546c12040c0a7ba0fd58e639f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 22 Dec 2009 18:16:46 -0500 Subject: re PR c++/42466 (Multiple instantiations of template constructor fail) PR c++/42466 * pt.c (reduce_template_parm_level): Check the type before returning cached TEMPLATE_PARM_INDEX. From-SVN: r155411 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/template/nontype19.C | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/nontype19.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b75e38a..65d40e2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2009-12-22 Jason Merrill + PR c++/42466 + * pt.c (reduce_template_parm_level): Check the type before + returning cached TEMPLATE_PARM_INDEX. + PR c++/42331 * typeck.c (cp_build_modify_expr): Fix thinko. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bb7c167..85ad539 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3356,7 +3356,8 @@ reduce_template_parm_level (tree index, tree type, int levels, tree args, { if (TEMPLATE_PARM_DESCENDANTS (index) == NULL_TREE || (TEMPLATE_PARM_LEVEL (TEMPLATE_PARM_DESCENDANTS (index)) - != TEMPLATE_PARM_LEVEL (index) - levels)) + != TEMPLATE_PARM_LEVEL (index) - levels) + || !same_type_p (type, TREE_TYPE (TEMPLATE_PARM_DESCENDANTS (index)))) { tree orig_decl = TEMPLATE_PARM_DECL (index); tree decl, t; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cfd4b5e..59d3a09 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2009-12-22 Jason Merrill + PR c++/42466 + * g++.dg/template/nontype19.C: New. + PR c++/42331 * g++.dg/cpp0x/initlist29.C: New. diff --git a/gcc/testsuite/g++.dg/template/nontype19.C b/gcc/testsuite/g++.dg/template/nontype19.C new file mode 100644 index 0000000..1df78b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nontype19.C @@ -0,0 +1,19 @@ +// PR c++/42466 + +template +struct A +{ + A(); + + template + A(const A& other); +}; + +int main(int argc, char** argv) +{ + A a; + A b = a; + + A c; + A d = c; +} -- cgit v1.1