From patchwork Thu Jul 20 09:33:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 12326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2995733vqt; Thu, 20 Jul 2023 02:34:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8JvzRhOSXmMhijJEjsB89Z3kRAJmiiHk95HtpzaClK2WQrx07TfyGpB7ws6QlRrrNEip+ X-Received: by 2002:a17:906:1d7:b0:993:da91:6e0c with SMTP id 23-20020a17090601d700b00993da916e0cmr4790813ejj.3.1689845683182; Thu, 20 Jul 2023 02:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689845683; cv=none; d=google.com; s=arc-20160816; b=gqDiYeqzIqnGR0GKkngIghphcf6rEHxongAGUCl3U1uNrmWbZ4jTmTc+aqJCaZigXl e0ZVBJ7nigp7qHy/EevY6Cx26Hd5nuUZCUWBuKbjsCMUy5hwbT4pSVco7J8AI1mnpWaY okkWaxqW0NfqVETh786LakwuM3kzCxBkH3mDuu33/WM43gRtlsgTEe5PZ7VXIvc1/EO4 FLTh9W3FGP6y4MJpXCMi5CG7TC4bDwIYQp90iYT3oXy2WyqLsgxbhddsF74co75zvaaO UMjfF+1VTnIjX8/0ZQBrFeLFEJWm4U3HgIpyHkhiOr+CgOS0qi7gevDEhDv0sPsT1IlX aEbg== 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=AWw+ChYu0lxRlTkHyuLJGm1miqBdUdxEQGsNj12SrFg=; fh=7hbAB8w2bVlX/0SB9H9Tjbu8At3vrCIhn/ALsGYzX6A=; b=d/HWvSJaKCZp0cmUXvU9lYZQgFiDQGqCArW6FRsmURWu8SUQaGhOkSAo/ImKcEXyFe bnLqSPLCGMO2woxmA/ygl9cbHMBd7/SYUMJ19RkU4xDtSOVprV83PMKfmZhrI50JGHBk NDJzQbNELqASOk2oiok8/pGfjM5Izvbg4ue5BLEYPcjBrhJyjrJWSv/GN8s4GezeB8Wl 9TQJFcSzT6jHoj6lqYfGhVPk746LNyLsmhzCYRcseypW5OdMiRzOBDiMJXlmWj/8kwUC A+PiY3VS02BS72g3cOrKiiaqEwxGlNA/UE0AGsVI5k19vCGznA4swHeXCmW6F7eyROy0 rBAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WWvpR9VP; 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=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y8-20020a170906470800b009882f2a8aabsi457175ejq.551.2023.07.20.02.34.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 02:34:43 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=WWvpR9VP; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF4BB385AF90 for ; Thu, 20 Jul 2023 09:34:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF4BB385AF90 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689845681; bh=AWw+ChYu0lxRlTkHyuLJGm1miqBdUdxEQGsNj12SrFg=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=WWvpR9VPWfycvhRUWZ6Akym4l2OVWmo4BWNt7UJ56vMB9lvFVmJyUJP2FZtxhRPe1 D10xIHGIjzprcyUjcx5JLpSHkR2tVdtWhP8r+GjloULv0Fb1+itZSL5biWp72dASr9 kiwEapp1R+yijJSvkKSs047/Qv6FnYNgs7cdVzsM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 543843858CDB for ; Thu, 20 Jul 2023 09:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 543843858CDB Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6b9ad292819so462283a34.2 for ; Thu, 20 Jul 2023 02:33:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689845627; x=1690450427; 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=AWw+ChYu0lxRlTkHyuLJGm1miqBdUdxEQGsNj12SrFg=; b=Nw927Uvd82jMimvQeVwZAWbMkvgWYeBf3lskKsIkm37vZRg1RNI5sF4e5WF7fjT4PS XLjKEnLTEz+EnHkpCTNxhVkpIWO+/appT9TUOGEE3PZ6su2SnwWW/KZe0z5uKX9nYDvG oKTxanj+4RxQOVW/lVxacRGd3kTDBMsWXIymK3+rHFdXyftT/b6R3SnYm70qKdxpOi96 hIKbYIuCesTF17WKjAcJIkqSKPFbjzPlnxATfa55RBuXaqunf4xH+QEbjGlO+D2Z405L GIvbOSJJNViWdS5SZkWD06vi6XikszZihYJEkrVp5DYS/G9fuYup/UAG3VQkII5Eg+2I tACQ== X-Gm-Message-State: ABy/qLaTTtqIF6pAYuRtQ7gxhFwMVuyM8Qf922/b1lk8pVLIGFUKXEnL 0QvWmnVDsOVMa+v/3DLYWab/TaCuuZA= X-Received: by 2002:a05:6358:3408:b0:134:28d6:be7 with SMTP id h8-20020a056358340800b0013428d60be7mr22423111rwd.9.1689845627012; Thu, 20 Jul 2023 02:33:47 -0700 (PDT) Received: from Thaum.localdomain (59-102-120-25.tpgi.com.au. [59.102.120.25]) by smtp.gmail.com with ESMTPSA id fm10-20020a056a002f8a00b006783ee5df8asm684886pfb.189.2023.07.20.02.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 02:33:46 -0700 (PDT) Date: Thu, 20 Jul 2023 19:33:40 +1000 To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Patrick Palka , Nathaniel Shead Subject: [PATCH v4 0/3] c++: Track lifetimes in constant evaluation [PR70331, ...] Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-5.5 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nathaniel Shead via Gcc-patches From: Nathaniel Shead Reply-To: Nathaniel Shead Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771931626996588933 X-GMAIL-MSGID: 1771931626996588933 This is an update of the patch series at https://gcc.gnu.org/pipermail/gcc-patches/2023-July/623375.html Changes since v3: - Use void_node in values map to indicate out-of-lifetime instead of a separate hash set - Remove tracking of temporaries for loops and calls - Fix missed checks for uses of empty classes outside lifetime and associated test - Add reference to PR c++/110619 for the second patch, and corresponding new test case Bootstrapped and regtested on x86_64-pc-linux-gnu. Nathaniel Shead (3): c++: Track lifetimes in constant evaluation [PR70331,PR96630,PR98675] c++: Improve constexpr error for dangling local variables [PR110619] c++: Improve location information in constant evaluation gcc/cp/constexpr.cc | 178 +++++++++++++----- gcc/cp/semantics.cc | 5 +- gcc/cp/typeck.cc | 5 +- 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 | 14 ++ .../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 +-- .../g++.dg/warn/Wreturn-local-addr-6.C | 3 - .../25_algorithms/equal/constexpr_neg.cc | 7 +- .../testsuite/26_numerics/gcd/105844.cc | 10 +- .../testsuite/26_numerics/lcm/105844.cc | 14 +- 50 files changed, 350 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