https://gcc.gnu.org/g:60e1e13f458f1fcfb05a30ace57fa682461e2732
commit r13-8669-g60e1e13f458f1fcfb05a30ace57fa682461e2732 Author: centurion <centurion...@proton.me> Date: Wed Mar 27 18:36:37 2024 +0000 c++: alias CTAD and template template parm [PR114377] To match all the other places that pull a _TEMPLATE_PARM out of a _DECL (get_template_parm_index, etc.). This change is too small to be legally significant for copyright. PR c++/114377 gcc/cp/ChangeLog: * pt.cc (find_template_parameter_info::found): Use TREE_TYPE for TEMPLATE_DECL instead of DECL_INITIAL. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias19.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit 801e82acd6b4f0cf863529875947e394899ea7b9) Diff: --- gcc/cp/pt.cc | 3 ++- gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index a768d11c82f..fa660fcf49e 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -10917,7 +10917,8 @@ find_template_parameter_info::found (tree parm) { if (TREE_CODE (parm) == TREE_LIST) parm = TREE_VALUE (parm); - if (TREE_CODE (parm) == TYPE_DECL) + if (TREE_CODE (parm) == TYPE_DECL + || TREE_CODE (parm) == TEMPLATE_DECL) parm = TREE_TYPE (parm); else parm = DECL_INITIAL (parm); diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C new file mode 100644 index 00000000000..1ea79bd7691 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C @@ -0,0 +1,15 @@ +// PR c++/114377 +// { dg-do compile { target c++20 } } + +template <template <typename> typename Iterator> +struct K {}; + +template <typename C, typename IteratorPolicy> +class Foo {}; + +template <typename C, template<typename> typename TTP> +using Bar = Foo<C, K<TTP>>; + +void s() { + Bar(1); // { dg-error "failed|no match" } +}