From dd809fdeca8088bb91e6414d834e3e322dcdf14c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 22 Dec 2016 10:19:54 -0500 Subject: [PATCH] PR c++/78898 - ICE on constructor with TTP PR c++/42329 * pt.c (unify): Don't look for a class template from a non-class. From-SVN: r243890 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/g++.dg/template/ttp30.C | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/ttp30.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 925d0b519bf..6f193c4e2db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-12-22 Jason Merrill + + 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 PR c++/72707 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 301eb5271ba..7711546f7b7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..f7b9ce7bfbc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp30.C @@ -0,0 +1,6 @@ +// PR c++/78898 + +struct A { + template A(T); + template