From 801e82acd6b4f0cf863529875947e394899ea7b9 Mon Sep 17 00:00:00 2001 From: centurion Date: Wed, 27 Mar 2024 18:36:37 +0000 Subject: [PATCH] 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 --- gcc/cp/pt.cc | 3 ++- .../g++.dg/cpp2a/class-deduction-alias19.C | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 7b00a8615d2..1425d6116d0 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -11032,7 +11032,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