From: Jason Merrill Date: Thu, 7 Mar 2019 16:15:56 +0000 (-0500) Subject: PR c++/88820 - ICE with CTAD and member template used in DMI. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae9b289201b6c6996b9c701109658adfb551327b;p=gcc.git PR c++/88820 - ICE with CTAD and member template used in DMI. Here the problem was that in order to form a FUNCTION_DECL for foo in the uninstantiated template, we were trying to deduce template args for S from the template parm itself, and failing. * pt.c (do_class_deduction): Handle parm used as its own arg. From-SVN: r269463 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c2162a4a3d4..94e278dc944 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-03-07 Jason Merrill + + PR c++/88820 - ICE with CTAD and member template used in DMI. + * pt.c (do_class_deduction): Handle parm used as its own arg. + 2019-03-07 Jakub Jelinek PR c++/89585 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8a5a0b38b2d..906cfe0a58c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -27184,6 +27184,9 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags, error ("non-class template %qT used without template arguments", tmpl); return error_mark_node; } + if (init && TREE_TYPE (init) == ptype) + /* Using the template parm as its own argument. */ + return ptype; tree type = TREE_TYPE (tmpl); diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C new file mode 100644 index 00000000000..3a06e6fb522 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C @@ -0,0 +1,9 @@ +// PR c++/88820 +// { dg-do compile { target c++17 } } + +template struct S; + +template struct W { + template static int foo(); + bool b = foo(); +};