public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/jason/heads/alias-ctad)] c++: CTAD for less-specialized alias template [PR102529] Date: Thu, 9 Feb 2023 23:01:22 +0000 (GMT) [thread overview] Message-ID: <20230209230122.55ABE385B50C@sourceware.org> (raw) https://gcc.gnu.org/g:e88e0337bac56ee087314fc26206bc86332c0dfc commit e88e0337bac56ee087314fc26206bc86332c0dfc Author: Jason Merrill <jason@redhat.com> Date: Thu Feb 9 12:58:35 2023 -0800 c++: CTAD for less-specialized alias template [PR102529] DR 2664 PR c++/102529 gcc/cp/ChangeLog: * pt.cc (alias_ctad_tweaks): Continue after deduction failure. gcc/testsuite/ChangeLog: * g++.dg/DRs/dr2664.C: New test. * g++.dg/cpp2a/class-deduction-alias15.C: New test. Diff: --- gcc/cp/pt.cc | 4 +++- gcc/testsuite/g++.dg/DRs/dr2664.C | 17 +++++++++++++++++ gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 35d8ce709c3..68488a0d018 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30057,7 +30057,9 @@ alias_ctad_tweaks (tree tmpl, tree uguides) tree targs = make_tree_vec (len); int err = unify (ftparms, targs, ret, utype, UNIFY_ALLOW_NONE, false); if (err) - continue; + /* CWG2664: Discard any deductions, still build the guide. */ + for (unsigned i = 0; i < len; ++i) + TREE_VEC_ELT (targs, i) = NULL_TREE; /* The number of parms for f' is the number of parms for A plus non-deduced parms of f. */ diff --git a/gcc/testsuite/g++.dg/DRs/dr2664.C b/gcc/testsuite/g++.dg/DRs/dr2664.C new file mode 100644 index 00000000000..f6bf8e2ecef --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr2664.C @@ -0,0 +1,17 @@ +// CWG 2664 +// { dg-do compile { target c++20 } } + +template <class S1, class S2> struct C { + C(...); +}; + +template<class T1> C(T1) -> C<T1, T1>; +template<class T1, class T2> C(T1, T2) -> C<T1 *, T2>; + +template<class V1, class V2> using A = C<V1, V2>; + +C c1{""}; +A a1{""}; + +C c2{"", 1}; +A a2{"", 1}; diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C new file mode 100644 index 00000000000..db615faf8e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C @@ -0,0 +1,18 @@ +// PR c++/102529 +// { dg-do compile { target c++20 } } + +template <typename T> +struct C { + template <typename U> + C(U); +}; + +template <typename U> +C(U) -> C<U*>; + +template <typename T> + requires true +using A = C<T>; + +C ok(1); // ok, a is a C<int*> +A bad(2); // fails
reply other threads:[~2023-02-09 23:01 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230209230122.55ABE385B50C@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).