]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: alias CTAD and template template parm [PR114377]
authorcenturion <centurion009@proton.me>
Wed, 27 Mar 2024 18:36:37 +0000 (18:36 +0000)
committerJason Merrill <jason@redhat.com>
Wed, 1 May 2024 19:30:33 +0000 (15:30 -0400)
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>
(cherry picked from commit 801e82acd6b4f0cf863529875947e394899ea7b9)

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

index a768d11c82f585e0eab7aac51695db961af3a7ba..fa660fcf49eeb34acbf8faab7fda6a330a92853d 100644 (file)
@@ -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 (file)
index 0000000..1ea79bd
--- /dev/null
@@ -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" }
+}