]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: alias CTAD in unevaluated context [PR101233]
authorPatrick Palka <ppalka@redhat.com>
Fri, 16 Jul 2021 20:21:13 +0000 (16:21 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 16 Jul 2021 20:27:31 +0000 (16:27 -0400)
This is the alias CTAD version of the CTAD bug PR93248, and the fix is
the same: clear cp_unevaluated_operand so that the entire chain of
DECL_ARGUMENTS gets substituted.

PR c++/101233

gcc/cp/ChangeLog:

* pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for
substituting DECL_ARGUMENTS.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias10.C: New test.

(cherry picked from commit a8b3861496bffae8b813ea196c1c5b27f79fbe69)

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

index b53b1fd9a977407663a60b0380a257a89392cc81..45f39ab7fff6934bf273062e86645453e6c01692 100644 (file)
@@ -29097,7 +29097,13 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
          /* Substitute the deduced arguments plus the rewritten template
             parameters into f to get g.  This covers the type, copyness,
             guideness, and explicit-specifier.  */
-         tree g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
+         tree g;
+           {
+             /* Parms are to have DECL_CHAIN tsubsted, which would be skipped
+                if cp_unevaluated_operand.  */
+             cp_evaluated ev;
+             g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
+           }
          if (g == error_mark_node)
            continue;
          DECL_USE_TEMPLATE (g) = 0;
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
new file mode 100644 (file)
index 0000000..a473fff
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/101233
+// { dg-do compile { target c++20 } }
+
+template<class T, class U>
+struct A { A(T, U); };
+
+template<class T, class U>
+using B = A<U, T>;
+
+using type = decltype(B{0, 0});