From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 55ABE385B50C; Thu, 9 Feb 2023 23:01:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55ABE385B50C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675983682; bh=c7DuGdTVMWeuxfd+8uNOv6EsFdflOsHZ+Qo7OUkOI60=; h=From:To:Subject:Date:From; b=nF1CHpkPAyJJbWXlnasjxaybIzFRFtjmQ+7tS8fNyG8z/5WqY6lRkjcvqRLsXze5/ b/eh/LuOcaJaeSdIX3d03qRu9vjXfSQLi15EK9SCKMyrynE2nhwMdjL4f/S1JGM12e KCAMXJKx3J4qjv8OtHheZfP+JW6q5rPea7DtdDp0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/jason/heads/alias-ctad)] c++: CTAD for less-specialized alias template [PR102529] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/users/jason/heads/alias-ctad X-Git-Oldrev: 5bec2588336f2bc70d6d93972c5132b4930c2218 X-Git-Newrev: e88e0337bac56ee087314fc26206bc86332c0dfc Message-Id: <20230209230122.55ABE385B50C@sourceware.org> Date: Thu, 9 Feb 2023 23:01:22 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e88e0337bac56ee087314fc26206bc86332c0dfc commit e88e0337bac56ee087314fc26206bc86332c0dfc Author: Jason Merrill 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 struct C { + C(...); +}; + +template C(T1) -> C; +template C(T1, T2) -> C; + +template using A = C; + +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 +struct C { + template + C(U); +}; + +template +C(U) -> C; + +template + requires true +using A = C; + +C ok(1); // ok, a is a C +A bad(2); // fails