c++: CTAD with alias and nested template [PR105655]
commit34970d08c6297e12f3f9117b6ac19fb2de522e24
authorJason Merrill <jason@redhat.com>
Wed, 25 May 2022 16:38:58 +0000 (25 12:38 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 25 May 2022 18:49:18 +0000 (25 14:49 -0400)
tree6ba9da082de8468325cbeb73cf29bac5dd5621d3
parent850a9ce8bcca59c7efabcdeeca14c5bd905e8363
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]