Message ID | ZLvx7bNUL0KLo+Iq@Thaum.localdomain |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp854027vqg; Sat, 22 Jul 2023 08:13:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFzsnmkxzIku2JFcRL/zf8sY0vxKBl9a7YosOfZO6yfUSXcDbVF4RS0/wPuRjDSe9D2/eaC X-Received: by 2002:aa7:cb59:0:b0:521:d275:c5a0 with SMTP id w25-20020aa7cb59000000b00521d275c5a0mr3911500edt.15.1690038828249; Sat, 22 Jul 2023 08:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690038828; cv=none; d=google.com; s=arc-20160816; b=Tw3H4HnpOW/XcBJiWkJ7jP1gpECf1ls+bdcWNroUdx+MVVSfZ/V7xmPaKnzH0rCMpV P1NGgscmvqGPDxytTxQQfqNQzCPWRwO/NGBcmZgRBzWyXb7LRjvf2qCH32dlP4/1XeYx ugQg4HdQdwqU6yqAvndCX5tuN4lPhDY9hxz900dIRnXsv2sSAg0+kJACmNebnbBwPi/6 CP/3bqbjhyXSZLfXx2N8ewRcpP+7h5DSYlLJQD5bNBJRBySLF3nOw+jIlwGWVAxqgqUn rz5HJPYm4UmItGkIao5slUpthKEyumfVbF1poSkp+PgKpjxfl46+rZzuBDFx+7hnwHWC 1btg== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=k0RZh41+aGcdJszLTLyQms2+y0XMVA4FVuhbtkqTWbI=; fh=7hbAB8w2bVlX/0SB9H9Tjbu8At3vrCIhn/ALsGYzX6A=; b=amJ0Hocj4/frWMuIAiTPqbeIP+QPMKN77NxxIVANcRpjKFaJgRX0r+w+TCYdJNOcG8 9u0kLTC9CuOuuxHJauRcZVP3Poarxn/ZkprcPlqhVYMVUzkv7gAy3PxtHG1nR4WJXi/Q AqW1o2nnOufuN+3A+Ut7o9c0H34IJRGJLDdT6uzqGWmYvw1U41MeL+eFZHs0qWOH84Kd JFoPkn/p5vvbjQcQYKPvXopqkvALuqv6FBBbqe6Wo+Xwo2GRMhmcLpFOa/tW7QdK0SjA mkbTMVpP/Raaz0GLXaEE3FgAIDm1ityWYtgk0LzGfhXu0YVp/x8Z3gc/06oraSD0q5U2 3abg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="EjO6ej/Q"; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c26-20020a056402121a00b0051e2304b8afsi3597687edw.102.2023.07.22.08.13.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jul 2023 08:13:48 -0700 (PDT) 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="EjO6ej/Q"; 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 ED0D1385C017 for <ouuuleilei@gmail.com>; Sat, 22 Jul 2023 15:13:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED0D1385C017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690038827; bh=k0RZh41+aGcdJszLTLyQms2+y0XMVA4FVuhbtkqTWbI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=EjO6ej/Qygm+JLls3FTiaR4+4X6JRXMpWbBHM5LOk9tAB8e+AZCmnx+/gpcM9DJra RnUcHtI4TMLWWno6m3ZGdjxHcTD0NYJAJSW6SrWCqPD77NCKyIUvnyB34pOM1FhWe+ 0zlOqM0kMVgJ0YNVq9cTNHyipbAftWUOmONartmE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id A1EC13858D1E for <gcc-patches@gcc.gnu.org>; Sat, 22 Jul 2023 15:12:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1EC13858D1E Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bb893e6365so1139895ad.2 for <gcc-patches@gcc.gnu.org>; Sat, 22 Jul 2023 08:12:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690038771; x=1690643571; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k0RZh41+aGcdJszLTLyQms2+y0XMVA4FVuhbtkqTWbI=; b=IO+vcUqYEjOaq7ZvSbHlgR8keDTi3a/XhuV7CbtgY4smVXKsTFyl3JBfyWnXrL4VGs ERnB9R+MFBrcKfHFsUf8FvImQKpi4icqhoIkAGRiHUwZz0vGiwDpgEMJ5FSPgfgiJhSi KECUPAWLdYogeMMcw1lQt01kD+eAzNC4ye/s6g921DZzA7G9eJ2pB87yjsdVM4YABYob pJtKH0z4d1gmCvnF0sWUd+GuL7vMOoQ0SJJLTzKXyoKDdRBMF3uHjoR2MA+uEp5F+LKN 1O8cDQVqG68gQ+xV/j11HunzJPnaHLFfJ/RReigGLMBHauoq7f7VDb6CQ7SFEKwzFPit sqPg== X-Gm-Message-State: ABy/qLY+pFm8bTYgaOCUWVFDLazDo+cRsCg6xV1/EO3f/b6YxeZF/VOl RDJi2msWn5eEp/vKVDhfFd7wDbsbN4o= X-Received: by 2002:a17:902:76c2:b0:1bb:91f2:bb3e with SMTP id j2-20020a17090276c200b001bb91f2bb3emr606646plt.49.1690038770856; Sat, 22 Jul 2023 08:12:50 -0700 (PDT) Received: from Thaum.localdomain (59-102-120-25.tpgi.com.au. [59.102.120.25]) by smtp.gmail.com with ESMTPSA id jg1-20020a17090326c100b001b86f1b5797sm5472869plb.302.2023.07.22.08.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jul 2023 08:12:50 -0700 (PDT) Date: Sun, 23 Jul 2023 01:12:45 +1000 To: gcc-patches@gcc.gnu.org Cc: Jason Merrill <jason@redhat.com>, Patrick Palka <ppalka@redhat.com>, Nathaniel Shead <nathanieloshead@gmail.com> Subject: [PATCH v5 0/3] c++: Track lifetimes in constant evaluation [PR70331, ...] Message-ID: <ZLvx7bNUL0KLo+Iq@Thaum.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URI_HEX 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 <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> From: Nathaniel Shead via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Nathaniel Shead <nathanieloshead@gmail.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772134154234399871 X-GMAIL-MSGID: 1772134154234399871 |
Series |
c++: Track lifetimes in constant evaluation [PR70331, ...]
|
|
Message
Nathaniel Shead
July 22, 2023, 3:12 p.m. UTC
This is an update of the patch series at https://gcc.gnu.org/pipermail/gcc-patches/2023-July/625050.html Changes since v4: - Reordered patches to be more independent from each other (they don't need to keep updating the new tests) - Removed workaround for better locations in cxx_eval_store_expression - Don't bother checking lifetime for CONST_DECLs - Rewrite patch for dangling pointers to keep the transformation to `return (&x, nullptr)`, but only perform it when genericising. It turns out that implementing this wasn't as hard as I thought it might be, at least for this specific case. Thanks very much for all the reviews and comments so far! Bootstrapped and regtested on x86_64-pc-linux-gnu. Nathaniel Shead (3): c++: Improve location information in constant evaluation c++: Prevent dangling pointers from becoming nullptr in constexpr [PR110619] c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675] gcc/cp/constexpr.cc | 159 +++++++++++++----- gcc/cp/cp-gimplify.cc | 23 ++- gcc/cp/cp-tree.h | 8 +- gcc/cp/semantics.cc | 4 +- gcc/cp/typeck.cc | 9 +- gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C | 10 +- gcc/testsuite/g++.dg/cpp0x/constexpr-70323.C | 8 +- gcc/testsuite/g++.dg/cpp0x/constexpr-70323a.C | 8 +- .../g++.dg/cpp0x/constexpr-delete2.C | 5 +- gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C | 2 +- gcc/testsuite/g++.dg/cpp0x/constexpr-ice20.C | 1 + .../g++.dg/cpp0x/constexpr-recursion.C | 6 +- gcc/testsuite/g++.dg/cpp0x/overflow1.C | 2 +- gcc/testsuite/g++.dg/cpp1y/constexpr-110619.C | 10 ++ gcc/testsuite/g++.dg/cpp1y/constexpr-89285.C | 5 +- gcc/testsuite/g++.dg/cpp1y/constexpr-89481.C | 3 +- .../g++.dg/cpp1y/constexpr-lifetime1.C | 13 ++ .../g++.dg/cpp1y/constexpr-lifetime2.C | 20 +++ .../g++.dg/cpp1y/constexpr-lifetime3.C | 13 ++ .../g++.dg/cpp1y/constexpr-lifetime4.C | 11 ++ .../g++.dg/cpp1y/constexpr-lifetime5.C | 11 ++ .../g++.dg/cpp1y/constexpr-lifetime6.C | 15 ++ .../g++.dg/cpp1y/constexpr-tracking-const14.C | 3 +- .../g++.dg/cpp1y/constexpr-tracking-const16.C | 3 +- .../g++.dg/cpp1y/constexpr-tracking-const18.C | 4 +- .../g++.dg/cpp1y/constexpr-tracking-const19.C | 4 +- .../g++.dg/cpp1y/constexpr-tracking-const21.C | 4 +- .../g++.dg/cpp1y/constexpr-tracking-const22.C | 4 +- .../g++.dg/cpp1y/constexpr-tracking-const3.C | 3 +- .../g++.dg/cpp1y/constexpr-tracking-const4.C | 3 +- .../g++.dg/cpp1y/constexpr-tracking-const7.C | 3 +- gcc/testsuite/g++.dg/cpp1y/constexpr-union5.C | 4 +- gcc/testsuite/g++.dg/cpp1y/pr68180.C | 4 +- .../g++.dg/cpp1z/constexpr-lambda6.C | 4 +- .../g++.dg/cpp1z/constexpr-lambda8.C | 5 +- gcc/testsuite/g++.dg/cpp2a/bit-cast11.C | 10 +- gcc/testsuite/g++.dg/cpp2a/bit-cast12.C | 10 +- gcc/testsuite/g++.dg/cpp2a/bit-cast14.C | 14 +- gcc/testsuite/g++.dg/cpp2a/constexpr-98122.C | 4 +- .../g++.dg/cpp2a/constexpr-dynamic17.C | 5 +- gcc/testsuite/g++.dg/cpp2a/constexpr-init1.C | 5 +- gcc/testsuite/g++.dg/cpp2a/constexpr-new12.C | 6 +- gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C | 10 +- gcc/testsuite/g++.dg/cpp2a/constinit10.C | 5 +- .../g++.dg/cpp2a/is-corresponding-member4.C | 4 +- gcc/testsuite/g++.dg/ext/constexpr-vla2.C | 4 +- gcc/testsuite/g++.dg/ext/constexpr-vla3.C | 4 +- gcc/testsuite/g++.dg/ubsan/pr63956.C | 23 +-- .../25_algorithms/equal/constexpr_neg.cc | 7 +- .../testsuite/26_numerics/gcd/105844.cc | 10 +- .../testsuite/26_numerics/lcm/105844.cc | 14 +- 51 files changed, 361 insertions(+), 168 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-110619.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime1.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime2.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime3.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime4.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime5.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime6.C
Comments
On 7/22/23 11:12, Nathaniel Shead wrote: > This is an update of the patch series at > https://gcc.gnu.org/pipermail/gcc-patches/2023-July/625050.html I applied the patches, with an addition to the first patch to fix constexpr-mutable3.C in C++11 mode, which was not part of the default std set. And fixed the testsuite to run that test (and others that test c++11_only behavior) in C++11 mode. Thanks! FWIW, I test C++ patches with GXX_TESTSUITE_STDS=98,11,14,17,20,impcx for more coverage. > Changes since v4: > > - Reordered patches to be more independent from each other (they don't need > to keep updating the new tests) > - Removed workaround for better locations in cxx_eval_store_expression > - Don't bother checking lifetime for CONST_DECLs > - Rewrite patch for dangling pointers to keep the transformation to > `return (&x, nullptr)`, but only perform it when genericising. It turns out > that implementing this wasn't as hard as I thought it might be, at least for > this specific case. > > Thanks very much for all the reviews and comments so far! > > Bootstrapped and regtested on x86_64-pc-linux-gnu. > > Nathaniel Shead (3): > c++: Improve location information in constant evaluation > c++: Prevent dangling pointers from becoming nullptr in constexpr > [PR110619] > c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675] > > gcc/cp/constexpr.cc | 159 +++++++++++++----- > gcc/cp/cp-gimplify.cc | 23 ++- > gcc/cp/cp-tree.h | 8 +- > gcc/cp/semantics.cc | 4 +- > gcc/cp/typeck.cc | 9 +- > gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C | 10 +- > gcc/testsuite/g++.dg/cpp0x/constexpr-70323.C | 8 +- > gcc/testsuite/g++.dg/cpp0x/constexpr-70323a.C | 8 +- > .../g++.dg/cpp0x/constexpr-delete2.C | 5 +- > gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C | 2 +- > gcc/testsuite/g++.dg/cpp0x/constexpr-ice20.C | 1 + > .../g++.dg/cpp0x/constexpr-recursion.C | 6 +- > gcc/testsuite/g++.dg/cpp0x/overflow1.C | 2 +- > gcc/testsuite/g++.dg/cpp1y/constexpr-110619.C | 10 ++ > gcc/testsuite/g++.dg/cpp1y/constexpr-89285.C | 5 +- > gcc/testsuite/g++.dg/cpp1y/constexpr-89481.C | 3 +- > .../g++.dg/cpp1y/constexpr-lifetime1.C | 13 ++ > .../g++.dg/cpp1y/constexpr-lifetime2.C | 20 +++ > .../g++.dg/cpp1y/constexpr-lifetime3.C | 13 ++ > .../g++.dg/cpp1y/constexpr-lifetime4.C | 11 ++ > .../g++.dg/cpp1y/constexpr-lifetime5.C | 11 ++ > .../g++.dg/cpp1y/constexpr-lifetime6.C | 15 ++ > .../g++.dg/cpp1y/constexpr-tracking-const14.C | 3 +- > .../g++.dg/cpp1y/constexpr-tracking-const16.C | 3 +- > .../g++.dg/cpp1y/constexpr-tracking-const18.C | 4 +- > .../g++.dg/cpp1y/constexpr-tracking-const19.C | 4 +- > .../g++.dg/cpp1y/constexpr-tracking-const21.C | 4 +- > .../g++.dg/cpp1y/constexpr-tracking-const22.C | 4 +- > .../g++.dg/cpp1y/constexpr-tracking-const3.C | 3 +- > .../g++.dg/cpp1y/constexpr-tracking-const4.C | 3 +- > .../g++.dg/cpp1y/constexpr-tracking-const7.C | 3 +- > gcc/testsuite/g++.dg/cpp1y/constexpr-union5.C | 4 +- > gcc/testsuite/g++.dg/cpp1y/pr68180.C | 4 +- > .../g++.dg/cpp1z/constexpr-lambda6.C | 4 +- > .../g++.dg/cpp1z/constexpr-lambda8.C | 5 +- > gcc/testsuite/g++.dg/cpp2a/bit-cast11.C | 10 +- > gcc/testsuite/g++.dg/cpp2a/bit-cast12.C | 10 +- > gcc/testsuite/g++.dg/cpp2a/bit-cast14.C | 14 +- > gcc/testsuite/g++.dg/cpp2a/constexpr-98122.C | 4 +- > .../g++.dg/cpp2a/constexpr-dynamic17.C | 5 +- > gcc/testsuite/g++.dg/cpp2a/constexpr-init1.C | 5 +- > gcc/testsuite/g++.dg/cpp2a/constexpr-new12.C | 6 +- > gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C | 10 +- > gcc/testsuite/g++.dg/cpp2a/constinit10.C | 5 +- > .../g++.dg/cpp2a/is-corresponding-member4.C | 4 +- > gcc/testsuite/g++.dg/ext/constexpr-vla2.C | 4 +- > gcc/testsuite/g++.dg/ext/constexpr-vla3.C | 4 +- > gcc/testsuite/g++.dg/ubsan/pr63956.C | 23 +-- > .../25_algorithms/equal/constexpr_neg.cc | 7 +- > .../testsuite/26_numerics/gcd/105844.cc | 10 +- > .../testsuite/26_numerics/lcm/105844.cc | 14 +- > 51 files changed, 361 insertions(+), 168 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-110619.C > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime1.C > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime2.C > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime3.C > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime4.C > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime5.C > create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime6.C >