]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/42466 (Multiple instantiations of template constructor fail)
authorJason Merrill <jason@redhat.com>
Tue, 22 Dec 2009 23:16:46 +0000 (18:16 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 22 Dec 2009 23:16:46 +0000 (18:16 -0500)
PR c++/42466
* pt.c (reduce_template_parm_level): Check the type before
returning cached TEMPLATE_PARM_INDEX.

From-SVN: r155411

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/nontype19.C [new file with mode: 0644]

index b75e38ac22d6560f0cc67d41944accde9849ae40..65d40e231e5842a71a812943acbb5e35ec51d3ad 100644 (file)
@@ -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.
 
index bb7c167ebe04308014bf15e44b98cc53cee40694..85ad539f419251881cdf2c0fbb4cf0039cf013c6 100644 (file)
@@ -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;
index cfd4b5ecf1e77baf4178f64444991af32b776ddb..59d3a09be2f3ff705a17c1781788f4ffaf6d1191 100644 (file)
@@ -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 (file)
index 0000000..1df78b3
--- /dev/null
@@ -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;
+}