public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8762] c++: alias CTAD in unevaluated context [PR101233]
@ 2021-07-16 22:49 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2021-07-16 22:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9107b139f4492d504df37e943882405e6aefdb7e

commit r11-8762-g9107b139f4492d504df37e943882405e6aefdb7e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 16 16:21:13 2021 -0400

    c++: alias CTAD in unevaluated context [PR101233]
    
    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)

Diff:
---
 gcc/cp/pt.c                                          |  8 +++++++-
 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C | 10 ++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b53b1fd9a97..45f39ab7fff 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 00000000000..a473fff5dc7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias10.C
@@ -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});


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-16 22:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 22:49 [gcc r11-8762] c++: alias CTAD in unevaluated context [PR101233] Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).