From patchwork Sat Jul 27 20:25:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1965670 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=N65OrW/9; 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 4WWbkD3Bwfz1yYc for ; Sun, 28 Jul 2024 06:26:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B10463857C4F for ; Sat, 27 Jul 2024 20:26:26 +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 B4F653858432 for ; Sat, 27 Jul 2024 20:26:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4F653858432 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 B4F653858432 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=1722111967; cv=none; b=BGNGgNR5ufqWVMl0+bI/KiWRJ92Tax8mcjGL0xIQUIaR+SwxdQC57ujK2AoJCu78oGmLxF5GL9WR5ec85fnBBas0qG8HHbcxo2GvaSPjc/3hk8IhZV30CU2Qz+QTxc0GPzZQnxU9VtorgyMW4vdrOtumJs7Dv4Es4UWb4sg2v6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722111967; c=relaxed/simple; bh=zA24yIxTiaiDBIBam/VI/j8N7DNr0/M6CVTZMC7t5/I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RkwYIF/r9AupmDTPukg/DYxouqnspl66/vPYkNDE2nwxDY5QF3D6zsb8Rymth1h791TJKtxeUEDku5szMXlUPud9ZvM2DvJdljEAAnExA5TghkYaYCgDyISVKa6VLHWV57aFYzKbB8NoxhMM9jMgo9tL6moDP11yb3C/4dsaszM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722111965; 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; bh=hv1qHSb3uCrU/n+gf2M9kAieDgfpw5h8p8Ed1N36pGY=; b=N65OrW/9c0OB8XXMHGkQOnqTDDDcI3ZExsS4NeDQDdOXDipQyuVMgMMnaHRFcjLAISt8at UXaA0DcZ3mDdrUyaGgQ5mcKUcBWixPChOMavRnFkfaMkkquHnBHzpXnJrCCyJf/0d/0jiy 7BdlMofRgn7rFpMDhb1T0yVHNhPiCp8= 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-592-DZsGWW3kPWisNYUX1Ea--w-1; Sat, 27 Jul 2024 16:26:03 -0400 X-MC-Unique: DZsGWW3kPWisNYUX1Ea--w-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b79810e326so27299846d6.3 for ; Sat, 27 Jul 2024 13:26:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722111963; x=1722716763; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hv1qHSb3uCrU/n+gf2M9kAieDgfpw5h8p8Ed1N36pGY=; b=QSyJgV97+vguhysp0fALD/66oGzEycO3Z6kVo/RxwiNXEPOOrPPoK29i4MjFCbmOPk n0n0HXWnFi6E11wACbONdcLGUVJNo4qs3W5Osud1ZjbMLOEcjQiRjfhzAmcAzcL2xq5g wfsub3BXhh4+/NmMpT/F4809uanoWWwFFbmvhltysVErO0K0Ff3dRkpbGmuBAgPgeHKF vsP3edYmdhxps/PjyUJ3JUTcTDbca5i3WuYbwVUEj1s7Fnv58ZmFKKvAcEOwIx8sh54g 9AmrqsSRPXWi+hE4frgZ4TPb3+hUT9TEF4z4PkbKDgvXNsYlotOi+zU8+1KM8MXRadKg 0cig== X-Gm-Message-State: AOJu0YyrOdIXGCFWShi5DYb0idc63HsSc1MGYADsuUW+/Y/mBBN4RhHB JzDOYnXAIWkIa6mEYKXNty3baqVnZpQDJxr7sAFpr6SSms8QQ7Un8jIy2uQ2bEMgY+bK3o3hRRs uprCGCdBphHJxYzjOEgQffqp8ApBpw+Fk8/dfI2WPg7Zz2WSZCWDH0f/qZFswLgxE9ib42M9Maq J8O0hIK7kgDrZZudp2HWCW8/DlVnYHw7kGRzU= X-Received: by 2002:a05:6214:d88:b0:6b5:44e4:eb3f with SMTP id 6a1803df08f44-6bb55ac9a7amr39012986d6.47.1722111962985; Sat, 27 Jul 2024 13:26:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHs3RFAUjClII9amzYOqWJndQ7pBhV+1qbSYOQwxMC1o8zwzXLKPNfIZMcnZXDVT64A2GaXIg== X-Received: by 2002:a05:6214:d88:b0:6b5:44e4:eb3f with SMTP id 6a1803df08f44-6bb55ac9a7amr39012946d6.47.1722111962465; Sat, 27 Jul 2024 13:26:02 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84e2sm33267726d6.21.2024.07.27.13.26.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jul 2024 13:26:01 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: ICE with concept, local class, and lambda [PR115561] Date: Sat, 27 Jul 2024 16:25:50 -0400 Message-ID: <20240727202600.3933837-1-jason@redhat.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_H4, 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 Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Here when we want to synthesize methods for foo()::B maybe_push_to_top_level calls push_function_context, which sets cfun to a dummy value; later finish_call_expr tries to set something in cp_function_chain (i.e. cfun->language), which isn't set. Many places in the compiler check cfun && cp_function_chain to avoid this problem; here we also want to check !cp_unevaluated_operand, like set_flags_from_callee does. PR c++/115561 gcc/cp/ChangeLog: * semantics.cc (finish_call_expr): Check cp_unevaluated_operand. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-lambda21.C: New test. --- gcc/cp/semantics.cc | 2 +- .../g++.dg/cpp2a/concepts-lambda21.C | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C base-commit: 928116e94a5a8a995dffd926af58abfa7286e78e diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 0f122b839c5..a9abf32e01f 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -2968,7 +2968,7 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, -Wredundant-move warning. */ suppress_warning (result, OPT_Wpessimizing_move); - if (cfun) + if (cfun && cp_function_chain && !cp_unevaluated_operand) { bool abnormal = true; for (lkp_iterator iter (maybe_get_fns (fn)); iter; ++iter) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C new file mode 100644 index 00000000000..8d701cd4bbc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C @@ -0,0 +1,69 @@ +// PR c++/115561 +// { dg-do compile { target c++20 } } + +template +auto declval() noexcept -> _Tp&&; + +template +struct enable_if +{ }; + +template +struct enable_if +{ using type = _Tp; }; + +template +using enable_if_t = typename enable_if<_Cond, _Tp>::type; + +template +struct is_void +{ static constexpr bool value = false; }; + +template +using invoke_result_t = + decltype(declval()(declval()...)); + +template +using iter_reference_t = decltype(*declval()); + +struct iter_move_fn +{ + template + constexpr + auto operator() (I &&i) -> void; +} iter_move; + +template +using iter_rvalue_reference_t = decltype(iter_move(declval())); + +template +concept same_as = true; + +template +concept readable_concept_ = + same_as, iter_rvalue_reference_t>; + +template +concept indirectly_readable = + readable_concept_>; + +template +using indirect_result_t = + enable_if_t, + invoke_result_t>>; + +template +concept transformable = + (!is_void>::value); + +template + requires transformable +constexpr void transform(I, Fun) +{ +} + +void foo() +{ + struct B {}; + (void) transform((B*)nullptr, [](B) {return 0; }); +}