diff options
author | Jason Merrill <jason@redhat.com> | 2009-12-22 18:16:46 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-12-22 18:16:46 -0500 |
commit | 2865105751562a5546c12040c0a7ba0fd58e639f (patch) | |
tree | c5aa6199fafa07e3534d7c437a1dc0f16acc46e3 /gcc | |
parent | 5666bb32d1861b6622a2f98b5e26fa7c8e3a310f (diff) | |
download | gcc-2865105751562a5546c12040c0a7ba0fd58e639f.zip gcc-2865105751562a5546c12040c0a7ba0fd58e639f.tar.gz gcc-2865105751562a5546c12040c0a7ba0fd58e639f.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/nontype19.C | 19 |
4 files changed, 28 insertions, 1 deletions
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 <jason@redhat.com> + 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 <jason@redhat.com> + 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<class IntT, IntT X> +struct A +{ + A(); + + template<IntT X2> + A(const A<IntT, X2>& other); +}; + +int main(int argc, char** argv) +{ + A<int, 42> a; + A<int, 100> b = a; + + A<unsigned, 42u> c; + A<unsigned, 100u> d = c; +} |