Message ID | 20231114210445.1469279-1-ppalka@redhat.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2202844rwb; Tue, 14 Nov 2023 13:05:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZZXEbJm4TSFBsQ8t1tccMdfFGwxUDPx91KlQJ/uTeoUYjKm4h8EwxeQKXR7fFTmQVuPfw X-Received: by 2002:a05:620a:4505:b0:76d:83ae:fdcd with SMTP id t5-20020a05620a450500b0076d83aefdcdmr3948224qkp.57.1699995919190; Tue, 14 Nov 2023 13:05:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699995919; cv=pass; d=google.com; s=arc-20160816; b=FjC8OSLlcyfg0TqPReR3buyPUDQq5+XtforqialXxDNMkD0Fob0iKgjFNz7AxZXeVm JZBvGqHOAhNrXIq7DXTcHkINGi1SJR4gBSj+cgaOym/DQFPzKkcKDtUQ2rpMN9b1U2Vt atE7s2CpJWKFcOZ+JDo8FH9pwKdspQ+KC3mzID0s7ILzEJDThBLm4Ftp+IZjVk+JfgTn utCAzSZJgXKbkHPaAhqptC8NYFd7b2W5rjSlFF/mL+g2FzOIAAfT5Gv+ak5Vd3qFanLg h5MY9FiwiFButZfVUp21vNFV8W65rm90tc+9c3r7LhWtuATux4pWlEOaq+k9jt4suYx+ 2cUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=D1X+ozh9FraElpLqzK2SUvjZe4fYlEAQ4uxoZXCIcww=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=r5fVy+rSGHTRpgiV9oYUEq3wQmP8pBWKF5TBp0a/9gqs/vJJMBeTTzbHnHSa7GAQnJ /4JaIBa2gMYU2PSf4cDZW4CiUmjfQIp51tn3oJKASalnv6ljARmQckyHlqDu8o1sYMv/ NzsZlIUTX9RzcO3sEDaupOw3KQLF2XSLMNQk58xjx7I28pOFz8xP0wyAn4gR3sQBVhoO IeQN3xziwg3HT4Mp70S57Ut0pjdo6nugKEEfYkJNW8OGvbjuOQZylkZEZXOiWfR5AsNA WK1Me6TNaqBw4AfbJFNI5+09lUHtqxNFLyQ46VibI7dINrt9n5iKlRROyuhfyqGIN36T NUmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BAqowTK5; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id az8-20020a05620a170800b00779d17610besi7801628qkb.349.2023.11.14.13.05.19 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 13:05:19 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BAqowTK5; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB6303858C74 for <ouuuleilei@gmail.com>; Tue, 14 Nov 2023 21:05:18 +0000 (GMT) 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 B7E343858D35 for <gcc-patches@gcc.gnu.org>; Tue, 14 Nov 2023 21:04:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7E343858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B7E343858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699995895; cv=none; b=AEDfWLttAfaZx4b/1EeuItCmySPUXRRdzyC4NU3g0jn2l41cI74WVVEguEKXutI50xUyKPh0U7uSLdl2Q6gQKgQqwfoDfBx3y0rnDlj5qL7hEAn5i4fCb732kC1VkMAr4gSODNW9Mq+VYupOcA3fj+4yIGQXnJXff71JgDeuL+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699995895; c=relaxed/simple; bh=k6FiTNbIFi/oy+3aH9IBI8TWtocShpXMfZLMRA/mm5g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wpxIHgxAyqZeDtBFMaWUrSkmIHLU+fi2smWfQxP5IYjQnxxaHpY1YGBr1bPMnvtr0NoX2+JZYc7WU8dEFHxGPQsGOFkYeiCPEECPYi4OLooo5cnxPHoax9tGeclap74U8efyPw9z8Wnh2r/AKEmw8A+XtxSAuhGAxrSnzTid11c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699995891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D1X+ozh9FraElpLqzK2SUvjZe4fYlEAQ4uxoZXCIcww=; b=BAqowTK5STJUGovbWXyl2vNhtU4pKMKXCoqWVJbLUlhBEu7CaigHnuLIXV51OWZ9eYzjXu /SqXIsSZqlVAtvIhKNPVirDoH6O+TZ21hzYvPMGBZ/ojQ82mAncM38Uzd9DQewwHdzGIpR e3HRPhjRW/TZ3moEYBpRUKJ5JeXl6Pw= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-h2C5coHXPfikpYSlNU5Jmg-1; Tue, 14 Nov 2023 16:04:50 -0500 X-MC-Unique: h2C5coHXPfikpYSlNU5Jmg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-77bc625a8a2so618169385a.0 for <gcc-patches@gcc.gnu.org>; Tue, 14 Nov 2023 13:04:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699995889; x=1700600689; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D1X+ozh9FraElpLqzK2SUvjZe4fYlEAQ4uxoZXCIcww=; b=msRLPf6TZ4MH3xlpqnOm/ETzoe/zox4wjdXH5B/0NA4IyUDhtUiHQsMxSRsPe5Qd16 nA/YiDXivRFLwdMse4gtgKwkXQZXQH405UuCx5XvuT/Wuixd/0UU1kMuSmtMugIaDBxG FO6ZEmFDpN6qsIsPEZJTesZHDn5MisNaHlYr8mJGUCyevrEs0BZ8ONGV6jNX5JS5cZ5t e6Af9KSqMWjQMjBfNfNxHzsP+yU09OVzDYZgA2fPi0Y0PWbTjKI8xM++X1qghYrXZuIK qFhfRDcC1AXXDsH3b+UVZHUvVgMQynnHyo1lwvHTqyv4sldcbJRDTntWj48uFBPgL416 ngCQ== X-Gm-Message-State: AOJu0Ywd3gdGf1kXTbcoDklhKfQTlVYi4NPWQkeFpodeJ44dYp9xAbV1 t8PFocsizmQQNsZhdmUjhZKWjAdgYZoB8j45ipfyH693jRVFSgja2jeXUpZCdMTiV/Fv5Byn7Ee lOQrNOWwatKEsGWPZ4J2frqif7tr0go13PUyZsx8W34SMUTFDHpv7wRILY+K25SRfh9oMizSNco 4= X-Received: by 2002:a05:620a:1201:b0:778:9156:3f07 with SMTP id u1-20020a05620a120100b0077891563f07mr3424215qkj.24.1699995889179; Tue, 14 Nov 2023 13:04:49 -0800 (PST) X-Received: by 2002:a05:620a:1201:b0:778:9156:3f07 with SMTP id u1-20020a05620a120100b0077891563f07mr3424193qkj.24.1699995888762; Tue, 14 Nov 2023 13:04:48 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id rg8-20020a05620a8ec800b00765ab6d3e81sm2913514qkn.122.2023.11.14.13.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 13:04:48 -0800 (PST) From: Patrick Palka <ppalka@redhat.com> To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka <ppalka@redhat.com> Subject: [PATCH] c++: partially inst requires-expr in noexcept-spec [PR101043] Date: Tue, 14 Nov 2023 16:04:45 -0500 Message-ID: <20231114210445.1469279-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.rc1 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=-13.6 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782574921009811988 X-GMAIL-MSGID: 1782574921009811988 |
Series |
c++: partially inst requires-expr in noexcept-spec [PR101043]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Patrick Palka
Nov. 14, 2023, 9:04 p.m. UTC
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- Here we're ICEing from strip_typedefs for the partially instantiated requires-expression when walking its REQUIRES_EXPR_EXTRA_ARGS since it's a TREE_LIST with non-empty TREE_PURPOSE (to hold the captured local specialization 't' as per build_extra_args) which strip_typedefs doesn't expect. We can probably skip walking REQUIRES_EXPR_EXTRA_ARGS at all since it shouldn't contain any typedefs in the first place, but it seems safer and more generally useful to just teach strip_typedefs to handle non-empty TREE_PURPOSE the obvious way. (The handling asserted TREE_PURPOSE was empty ever since inception i.e. r189298.) PR c++/101043 gcc/cp/ChangeLog: * tree.cc (strip_typedefs_expr) <case TREE_LIST>: Handle non-empty TREE_PURPOSE. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires37.C: New test. --- gcc/cp/tree.cc | 19 ++++++++++++------- .../g++.dg/cpp2a/concepts-requires37.C | 11 +++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C
Comments
On 11/14/23 16:04, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > -- >8 -- > > Here we're ICEing from strip_typedefs for the partially instantiated > requires-expression when walking its REQUIRES_EXPR_EXTRA_ARGS since it's > a TREE_LIST with non-empty TREE_PURPOSE (to hold the captured local > specialization 't' as per build_extra_args) which strip_typedefs doesn't > expect. > > We can probably skip walking REQUIRES_EXPR_EXTRA_ARGS at all since it > shouldn't contain any typedefs in the first place, but it seems safer > and more generally useful to just teach strip_typedefs to handle non-empty > TREE_PURPOSE the obvious way. (The handling asserted TREE_PURPOSE was > empty ever since inception i.e. r189298.) > > PR c++/101043 > > gcc/cp/ChangeLog: > > * tree.cc (strip_typedefs_expr) <case TREE_LIST>: Handle > non-empty TREE_PURPOSE. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/concepts-requires37.C: New test. > --- > gcc/cp/tree.cc | 19 ++++++++++++------- > .../g++.dg/cpp2a/concepts-requires37.C | 11 +++++++++++ > 2 files changed, 23 insertions(+), 7 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc > index dc4126f935c..0736e8d8f48 100644 > --- a/gcc/cp/tree.cc > +++ b/gcc/cp/tree.cc > @@ -1911,19 +1911,24 @@ strip_typedefs_expr (tree t, bool *remove_attributes, unsigned int flags) > case TREE_LIST: > { > bool changed = false; > - releasing_vec vec; > + auto_vec<tree_pair, 4> vec; > r = t; > for (; t; t = TREE_CHAIN (t)) > { > - gcc_assert (!TREE_PURPOSE (t)); > - tree elt = strip_typedefs (TREE_VALUE (t), > - remove_attributes, flags); > - if (elt != TREE_VALUE (t)) > + tree purpose = strip_typedefs (TREE_PURPOSE (t), > + remove_attributes, flags); > + tree value = strip_typedefs (TREE_VALUE (t), > + remove_attributes, flags); > + if (purpose != TREE_PURPOSE (t) || value != TREE_VALUE (t)) > changed = true; > - vec_safe_push (vec, elt); > + vec.safe_push ({purpose, value}); > } > if (changed) > - r = build_tree_list_vec (vec); > + { > + r = NULL_TREE; > + for (int i = vec.length () - 1; i >= 0; i--) > + r = tree_cons (vec[i].first, vec[i].second, r); > + } > return r; > } > > diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C > new file mode 100644 > index 00000000000..72dad77fea1 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C > @@ -0,0 +1,11 @@ > +// PR c++/101043 > +// { dg-do compile { target c++20 } } > + > +template<class T> > +void f(T t) { > + [&](auto) noexcept(requires { { t.g() }; }) { }(0); > +} > + > +int main() { > + f(0); > +}
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index dc4126f935c..0736e8d8f48 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -1911,19 +1911,24 @@ strip_typedefs_expr (tree t, bool *remove_attributes, unsigned int flags) case TREE_LIST: { bool changed = false; - releasing_vec vec; + auto_vec<tree_pair, 4> vec; r = t; for (; t; t = TREE_CHAIN (t)) { - gcc_assert (!TREE_PURPOSE (t)); - tree elt = strip_typedefs (TREE_VALUE (t), - remove_attributes, flags); - if (elt != TREE_VALUE (t)) + tree purpose = strip_typedefs (TREE_PURPOSE (t), + remove_attributes, flags); + tree value = strip_typedefs (TREE_VALUE (t), + remove_attributes, flags); + if (purpose != TREE_PURPOSE (t) || value != TREE_VALUE (t)) changed = true; - vec_safe_push (vec, elt); + vec.safe_push ({purpose, value}); } if (changed) - r = build_tree_list_vec (vec); + { + r = NULL_TREE; + for (int i = vec.length () - 1; i >= 0; i--) + r = tree_cons (vec[i].first, vec[i].second, r); + } return r; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C new file mode 100644 index 00000000000..72dad77fea1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires37.C @@ -0,0 +1,11 @@ +// PR c++/101043 +// { dg-do compile { target c++20 } } + +template<class T> +void f(T t) { + [&](auto) noexcept(requires { { t.g() }; }) { }(0); +} + +int main() { + f(0); +}