c++: CTAD with alias and nested template [PR105655]
authorJason Merrill <jason@redhat.com>
Wed, 25 May 2022 16:38:58 +0000 (12:38 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 31 May 2022 19:31:03 +0000 (15:31 -0400)
commitd81be519fd6547654f1eda6976e95524db7d39b7
treeb12cf206b05cf94c0cbf9e18d28f7b1fbf75f1f9
parentd90576952356735a2152c318ef1d60221b958b15
c++: CTAD with alias and nested template [PR105655]

Here, alias_ctad_tweaks expect tsubst_decl of a FUNCTION_DECL to return a
FUNCTION_DECL.  A reasonable expectation, but in this case we were replacing
the template args of the class-scope deduction guide with equivalent args,
so looking in the hash table we found the partial instantiation stored when
instantiating A<int>, which is a TEMPLATE_DECL.  It's fine for that to be
what is stored, but tsubst_function_decl should never return it.

PR c++/105655

gcc/cp/ChangeLog:

* pt.cc (build_template_decl): Add assert.
(tsubst_function_decl): Don't return a template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias13.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/class-deduction-alias13.C [new file with mode: 0644]