From patchwork Sat Feb 18 21:42:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 59027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp562840wrn; Sat, 18 Feb 2023 13:44:10 -0800 (PST) X-Google-Smtp-Source: AK7set/zt+wauS/gAOYG3RNCtpEDvkhp22Aw1JlqK+l24QWCe9ql2ARsqyic4MNerieY094dOLex X-Received: by 2002:a17:906:792:b0:8b1:94cc:4a6b with SMTP id l18-20020a170906079200b008b194cc4a6bmr6935325ejc.37.1676756649948; Sat, 18 Feb 2023 13:44:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676756649; cv=none; d=google.com; s=arc-20160816; b=Sig+U7e0PDg4+ysAJ7zNe6HECde2jFcs72cxNTDvZ/Tb28CklYBuxpvtYONuWyqejj w6JI4Y09vQuk92ifqKvS+91EiYe/HfBT+ulSgh6VTbqMa7evwWRPQmgHSLxy7kxETg62 g4WC4cFdNBTacHuyBg08XcDYlJ9RPc+i2J92l5N3hLbFrw6UOKUbVG+BoSm+7JiQpwZn smNM3rOmI6HH/3H1nFhg+vTYdZGyPqLdY0nOOdD3xJta1u7MO7wGgO43X/ik1BbmQ3ep Skq6TuYPvDPiGLm+waEklz446sXOKTRyfCS25QDSlQghFRZaS7KtVabXgLnItknHQnXz XMdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=XIQL1hfAHgbPG9IhkhIwjvZT6aFB17R1yin7hcae0XQ=; b=0O8uZYcVt67/rDzEk7JX4uBq+82da8sfmtfQfZPpS7JtzqanXV6O2UCR76TCVqoQyE Lw5Iq171ztMpPT5Uz/rRHS6/kqfkr0GIvmVhex1d18MCwepUVXQp3hypYLdbha9nDR3V UpszjWvIOcw4KBWQUPcMGPqWw3e0SpEX+8gHb0Trh8m8MsJ8T/4YBBxEx9S6iPfYwJ9Z JaNdFFUVz8u2LK3WsTkuZiZCWc1zmj5BXbCMq4SR8NwfFaUjuduaut+Y+U3RVOuUS6JV 2SCAOR6EJa3fYxbg+UMWgLYbmNyMboaPMr2rhrpphQW6/TDv36LxyAcPKi/EfqNJv5E8 q7iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J71D5tqa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d8-20020a056402516800b004acb4614ed5si654002ede.117.2023.02.18.13.44.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 13:44:09 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J71D5tqa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A71F03846414 for ; Sat, 18 Feb 2023 21:43:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A71F03846414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676756613; bh=XIQL1hfAHgbPG9IhkhIwjvZT6aFB17R1yin7hcae0XQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=J71D5tqayTWCXD4NfA/wj6H3wf72Dy8UJM/c/pzWb7MYW8c6YCJYCcoWDkx4PObpN GOznf70XC0oravUi558k92VjB95aRLw1PqQn0ROOqYgRyM5898sKvbiZqJ7X+frrEa 6aWVH7xcvymmhDqcO7efAeoqVF4VkGwLwNtSUVqU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id AE4913858D3C for ; Sat, 18 Feb 2023 21:42:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE4913858D3C Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-572-ig83LRplO4qFuK7tIv6hxA-1; Sat, 18 Feb 2023 16:42:46 -0500 X-MC-Unique: ig83LRplO4qFuK7tIv6hxA-1 Received: by mail-qt1-f198.google.com with SMTP id z16-20020ac84550000000b003b849aa2cd6so415757qtn.15 for ; Sat, 18 Feb 2023 13:42:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XIQL1hfAHgbPG9IhkhIwjvZT6aFB17R1yin7hcae0XQ=; b=FynXn4VvHJ0bg56Nbn3gHxtWnxw9FJqw2cBCZ7N7QLVKxZZ+EJWXDoaJtpSWNH3wsn 18LzLpTXNbI0KLqHqCURBf1dk1IDVIGaXMUdbHMNYuAmFF54pBgdSnEnj6w6mcVE23ld ucbTsrxlwASKu98J8dUbDwGrkxmTx0HDJ13JhN8KR6IBb7JXpfizUAX4loZL8dkydeEI UOUFD9CTUlQggcunTo2AfasFt/qYqZA+qM7phbnJT6jFJ7Lc95W6xCZJedCAmRo1fFrQ 5VmCGQI/iJIgbBr6WM6dLVGGjl+tmeij69VwHDyzMcU/6P+b1qPl9VrP3yfU81+gFnxw KGaQ== X-Gm-Message-State: AO0yUKWtd1a3NRdeK98yqYZ/cP8LwOQLyxd1BA699fARwHCVpdfGemls 2BlAyaz7VrkQJcCCF7+bm9wGAs1gcqsdSqS3WuR/CJ3pOsQpc3IHgxvwDQqh9/1R8MFvomI4kTi 6pMRyaj7Dp0aWfIoRwFbKPEd0v5bBvxeatjh7rHFo5W8Tyz8l2N3zXC/SWj3s8rT+OejKVWk= X-Received: by 2002:a05:6214:d49:b0:56e:c00c:bf5c with SMTP id 9-20020a0562140d4900b0056ec00cbf5cmr824775qvr.31.1676756565617; Sat, 18 Feb 2023 13:42:45 -0800 (PST) X-Received: by 2002:a05:6214:d49:b0:56e:c00c:bf5c with SMTP id 9-20020a0562140d4900b0056ec00cbf5cmr824756qvr.31.1676756565220; Sat, 18 Feb 2023 13:42:45 -0800 (PST) Received: from jason.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id u62-20020a372e41000000b0073d85e77fa9sm263717qkh.74.2023.02.18.13.42.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 13:42:44 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/3] c++: CTAD for less-specialized alias template [PR102529] Date: Sat, 18 Feb 2023 16:42:39 -0500 Message-Id: <20230218214239.2297623-3-jason@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230218214239.2297623-1-jason@redhat.com> References: <20230218214239.2297623-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758206780866970489?= X-GMAIL-MSGID: =?utf-8?q?1758206780866970489?= The standard was unclear what happens with the transformation of a deduction guide if the initial template argument deduction fails for a reason other than not deducing all the arguments; my implementation assumed that the right thing was to give up on the deduction guide. But in consideration of CWG2664 this week I realized that we get a better result by just continuing with an empty set of deductions, so the alias deduction guide is the same as the original deduction guide plus the deducible constraint. 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. --- gcc/cp/pt.cc | 4 +++- gcc/testsuite/g++.dg/DRs/dr2664.C | 17 +++++++++++++++++ .../g++.dg/cpp2a/class-deduction-alias15.C | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/DRs/dr2664.C create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 1934c9dafac..69391450b75 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30063,7 +30063,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