From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676756568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XIQL1hfAHgbPG9IhkhIwjvZT6aFB17R1yin7hcae0XQ=; b=NHLsrcSCDWNIlPRbm8B+Gg4LokTDEYK/uiJe9ZKgVouKjtaaK5fMPS131GjZ+6PSliFLWR /7TTBIOjQca6ZyreWWs2baeUQWphYCCNF2R1umuUA+wy44T6aHDB0hDzn+6w+sl1cAxovM ORYTOzax63FibDhqWfZddA+nlASrq94= 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-Google-Smtp-Source: AK7set8xjqeuBxvLGTJjmM8uOrUrYN2T0hRZJomslJJ48zKzK3C5D/AvKokn4jjzw5ErEj+ExF87KA== 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) From: Jason Merrill 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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 -- 2.31.1