PR c++/78898 - ICE on constructor with TTP
authorJason Merrill <jason@redhat.com>
Thu, 22 Dec 2016 15:19:54 +0000 (10:19 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 22 Dec 2016 15:19:54 +0000 (10:19 -0500)
PR c++/42329
* pt.c (unify): Don't look for a class template from a non-class.

From-SVN: r243890

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

index 925d0b519bf27938e07c4c374da02909ccbda662..6f193c4e2dba5e569ebb0cbd2e2eafb01ec6fe2c 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/78898
+       PR c++/42329
+       * pt.c (unify): Don't look for a class template from a non-class.
+
 2016-12-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/72707
index 301eb5271bae5779c2e870191b4992f625a06206..7711546f7b79ae464aa16083d4ae97f62e815dd2 100644 (file)
@@ -20292,7 +20292,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
 
       if (TREE_CODE (parm) == BOUND_TEMPLATE_TEMPLATE_PARM)
        {
-         if (strict_in & UNIFY_ALLOW_DERIVED)
+         if ((strict_in & UNIFY_ALLOW_DERIVED)
+             && CLASS_TYPE_P (arg))
            {
              /* First try to match ARG directly.  */
              tree t = try_class_unification (tparms, targs, parm, arg,
diff --git a/gcc/testsuite/g++.dg/template/ttp30.C b/gcc/testsuite/g++.dg/template/ttp30.C
new file mode 100644 (file)
index 0000000..f7b9ce7
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/78898
+
+struct A {
+  template <class T> A(T);
+  template <template <typename> class SmartPtr> A(SmartPtr<int>) { A(0); }
+};