aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcenturion <centurion009@proton.me>2024-03-27 18:36:37 +0000
committerJason Merrill <jason@redhat.com>2024-04-04 17:18:56 -0400
commit801e82acd6b4f0cf863529875947e394899ea7b9 (patch)
tree07f31a4279973af8794c38ca7eff160e7c221c8e
parentca56b43105fc09021ec445f1978a17cd85ae5e0c (diff)
downloadgcc-801e82acd6b4f0cf863529875947e394899ea7b9.zip
gcc-801e82acd6b4f0cf863529875947e394899ea7b9.tar.gz
gcc-801e82acd6b4f0cf863529875947e394899ea7b9.tar.bz2
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 <jason@redhat.com>
-rw-r--r--gcc/cp/pt.cc3
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C15
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 7b00a86..1425d61 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 0000000..1ea79bd
--- /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" }
+}