From patchwork Tue Oct 15 04:48:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1997194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=a/svrkgq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSM7s0tFjz1xvK for ; Tue, 15 Oct 2024 15:49:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 535C63857C6D for ; Tue, 15 Oct 2024 04:49:11 +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 ESMTP id 3AB993857B9E for ; Tue, 15 Oct 2024 04:48:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AB993857B9E 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 3AB993857B9E 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=1728967731; cv=none; b=uvFvOrOFunUeDbzWOsHClLNRig/5TSJTREHM01aWKxie7UCFz5jBU5E/tOSC9xKFZJH7BOPtlh4l7qa3cjY+CRSeqGFrnR3uN+Eo6Qm8QQD5gK3q39Rbuq14Gy9Jxte5EqxEQFkpx7WXznpeVK5f0aOCD8qOtUoYjiNAKjGQDuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728967731; c=relaxed/simple; bh=LSFCkzMc2K2wxrmE7Px+y6XIbpD6j3D3amP9ydRGlMQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kgy+goSyDhS2Wo6pP41H/TMvnqqBW+oPWuLEuZ8UD9e6Rz6TF4Web2PCMQBMTI6b6Qj8MUIDrm8xagEYzWth73T8CruiY6T1vZ3RoX2UCrBZC94UwIZO/F7x1qXx5TP/YFcGiTqb0hVK7ABSlf5xFflpYeRbOL5K3PTIYLYeAto= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728967728; 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=6ZNVk/JGwMMBDBFxJjmb39GaKAsQHWQQVtwYTSLUCF4=; b=a/svrkgqKF8ypSXE8H7l1Ul8mUP3VN+WTxlpq0Uon26LaiV3ewGgVZ+nPky+fo2A11qA7L l8g8os3oEjw4o5dlIXb+ij4DEwfT8aPSt4KwEXSeGC5q7xD+5qzvWXO3RJhhKEszIoVqZl C4h7BzBWSE96P1BGSE+/3uEIp56CBrI= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-Sh1ZC8-LMgy2vSwCNnV2Bg-1; Tue, 15 Oct 2024 00:48:31 -0400 X-MC-Unique: Sh1ZC8-LMgy2vSwCNnV2Bg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cbe149b1cfso13761416d6.0 for ; Mon, 14 Oct 2024 21:48:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728967710; x=1729572510; 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=6ZNVk/JGwMMBDBFxJjmb39GaKAsQHWQQVtwYTSLUCF4=; b=Gi0KtisNkZimtLfVOD6egfNpjy/vCMFAe7FUeTLaU+EVlcOHwEFsr0mGcrF0Zwc81G ILEmF2qKEP+9xnuxXXmVxX/Ndy1hj7arKekHBfxzYiefkWB1mfdf8tQ70J5gWc1qZ6vU 3uXFnJYZHPC1EA8uR3ifQa3huKDbmHsJmRGouEFUnEwyfWcgbreTB/kITiXiV7izu8X+ Vs9lAVoz8u5qQ6W56MzVTt9hdWjOOtWrVA3lHDmJzYv4IBLRdkoSL1f2uzY7z9fwelKw fkTfIECAwAAbQeBn1dBWxcPsXg0G1Ioa5pGL0MxS7NvZjVTxLT65jbPRKAB8x5AaYhom y4tg== X-Gm-Message-State: AOJu0YxON8x6bBYxOxh9ro+bqCFLTubzmepJIq7EX745RuOoQN7c26oB od1qm8WxuCO64j0CdiBLBIeP+qLaY5v57m4+KOxRxuZ0Z2kDBiZmzCCWWJdlL4nCABFuIeLeuM3 CvSLmPkbRDQbnRIe6eCGZRV1O+Mo7mQfgGErYmUq//4aJJIberr3Lnt6Ba12Jdyi6e9dYnCR+9u LRsq9syTfqU0OeBCZsZdRHfKa9GyrTtS+pmzUm X-Received: by 2002:a05:6214:2b4:b0:6cb:e7e8:9e88 with SMTP id 6a1803df08f44-6cbf000340dmr85794356d6.10.1728967710316; Mon, 14 Oct 2024 21:48:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhQYCVQ0WO2AO95aAhHT6aiziI5LmN+Ae60KGlwh0m22ICVdpkHZE5APBw5YgnyW/8jup5cw== X-Received: by 2002:a05:6214:2b4:b0:6cb:e7e8:9e88 with SMTP id 6a1803df08f44-6cbf000340dmr85794286d6.10.1728967709908; Mon, 14 Oct 2024 21:48:29 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cc2290fe8csm2453536d6.14.2024.10.14.21.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 21:48:28 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: checking ICE w/ lambda targ inside constexpr if [PR117054] Date: Tue, 15 Oct 2024 00:48:21 -0400 Message-ID: <20241015044821.1488337-1-ppalka@redhat.com> X-Mailer: git-send-email 2.47.0.72.gef8ce8f3d4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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_H3, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- Here we're tripping over the assert in extract_locals_r which enforces that an extra-args tree appearing inside another extra-args tree doesn't actually have extra args. This invariant no longer always holds for lambdas (which recently gained the extra-args mechanism), but it should be safe to just disable the assert for them since cp_walk_subtrees doesn't walk LAMBDA_EXPR_EXTRA_ARGS and so should be immune to the PR114303 issue for now. PR c++/117054 gcc/cp/ChangeLog: * pt.cc (extract_locals_r): Disable tree_extra_args assert for LAMBDA_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-targ9.C: New test. --- gcc/cp/pt.cc | 7 ++++++- gcc/testsuite/g++.dg/cpp2a/lambda-targ9.C | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/lambda-targ9.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index c7cbf6df26c..b90447ae6a2 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13479,7 +13479,12 @@ extract_locals_r (tree *tp, int *walk_subtrees, void *data_) outermost tree. Nested *_EXTRA_ARGS should naturally be empty since the outermost (extra-args) tree will intercept any substitution before a nested tree can. */ - gcc_checking_assert (tree_extra_args (*tp) == NULL_TREE); + gcc_checking_assert (tree_extra_args (*tp) == NULL_TREE + /* Except a lambda nested inside an extra-args tree + can have extra args if we deferred partial + substitution into it at template parse time. But + we don't walk LAMBDA_EXPR_EXTRA_ARGS anyway. */ + || TREE_CODE (*tp) == LAMBDA_EXPR); if (TREE_CODE (*tp) == DECL_EXPR) { diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-targ9.C b/gcc/testsuite/g++.dg/cpp2a/lambda-targ9.C new file mode 100644 index 00000000000..00dd4b2406e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-targ9.C @@ -0,0 +1,16 @@ +// PR c++/117054 +// { dg-do compile { target c++20 } } + +template +constexpr bool a = true; + +template +void f() { + [](auto) { + if constexpr (a<>) {} + }; +} + +int main() { + f(); +}