From patchwork Thu Aug 8 18:38:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1970686 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=Tcuw43Ew; 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 4Wfwn26gShz1yf8 for ; Fri, 9 Aug 2024 04:39:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 366B4385DDE5 for ; Thu, 8 Aug 2024 18:39:17 +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 4AA3C3858D20 for ; Thu, 8 Aug 2024 18:38:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AA3C3858D20 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 4AA3C3858D20 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=1723142321; cv=none; b=K/7mZCU+1mUxHbaWar0/5mL9SnM6N5y6Ft18lOHD2Bj8i5h7F+VjuRwnRyJ/WvJpi9gAZCBKc7j5NinEb0s4DpJ/n8I9iT7bk+8KwvxUjYlu8t2JVtAu79C8XpHHXY2T4SjBgvXXMZId0AttVzb2hZPOP1fYecii4fiV8WvEUJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723142321; c=relaxed/simple; bh=LTd9oVU4Li7dERxftN72Vwi39XZjzO+jHaABCljAP7Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Fv7/rDbvhdQ7MKA0MzSy4BSImM08j0XsefHR4g/nXkvIyfy+kJt4aO2ZbWJYMmKi5fvnA7PwEN1tbRnvWwn330UacJJbx4Ti9TSPl9NBLfYXDdbgzFBerttCvkgNhgkN3Ez7GKVfW80fyvLQYQlOZP4X+vSp/Hmip3F8KsuQj1c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723142319; 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=BVpCHrSJs8Fl8/yHeQIJWrRrH39p402rVmvy20u7UQQ=; b=Tcuw43EwLCwXHrj+5aU2CKTqb3bXXCj0N+XzNXWWpF8IG0ObHqwhDyUyWbc55mipstRupB xk51B83OJhZsIucnVcct+Q0ZTmvW/T+WnTH0NWjBy3GdrwzpqFu2nuMtRaRtSnZOWfxSNn N2+Ni8eJ0sPuT3nyLmj8FrNCzyjXjZE= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-pQBht9O0PsunC5KFcpTO5w-1; Thu, 08 Aug 2024 14:38:38 -0400 X-MC-Unique: pQBht9O0PsunC5KFcpTO5w-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-44ffa2bf13fso16130151cf.3 for ; Thu, 08 Aug 2024 11:38:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723142318; x=1723747118; 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=BVpCHrSJs8Fl8/yHeQIJWrRrH39p402rVmvy20u7UQQ=; b=FcxBrYsmLpqipvD5JRhrd6oz0vd8HpbMtrONOu5tBuP+T3wk/1sdhunQAQyDMceZ// KGccstqJwogFNsJ7d0UK/JTqZG3+ZBTEL6RLZ88AXBQvcnh5CJyC+6TNm/JlJHOo/2t/ d73l4lZWmfEQARSxrjq6U5fcgyKPbdRLpkcoLZnvGmw/Nxx0fh4uMjFYHUbP4OViB62Y qBW4AGqbZvChAoflhjKbyi9uvVAAjZNvdzVzS94nZaYkP+cZJppa1U4hMlsMbTzb5C0u xcxLkdHkrKK3sGelabkQh4xbJAeZ8Tsb/Vvc3pkC5uT7+ctccMFviymXtdaLcjjrbDlo ljpw== X-Gm-Message-State: AOJu0YxoA9W5tr+Y8ISDi2zPq3eWBj2DSLZVT86Uu0yb5IJH1LpUnUJY hD1VuPxjXoIspbNcu3YpbHXypV7m3cNwbiJYZrHSC/r6o7q0sR+AD08LATkuQt3YrBpBGhHTcNp sHTVcdSovtV5DLWhXgC5/9EQ+ft1c0vxbMg8XGGOAOmzLxaBj1FbDitUz1WcRcVxeew8IrwMZqn Lr6Zcdb2fqVfSdpLFvJdoZ57usEjJRAEV/HcMt X-Received: by 2002:a05:622a:4c0d:b0:451:d859:204c with SMTP id d75a77b69052e-451d85928d9mr21001101cf.64.1723142317762; Thu, 08 Aug 2024 11:38:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtOw7TVgPwPXVPlcn3CaTFL2r94+k4ha7xuzRg+IWA/bYYeDUed6dI+PwkBtGn43pxk+KKkQ== X-Received: by 2002:a05:622a:4c0d:b0:451:d859:204c with SMTP id d75a77b69052e-451d85928d9mr21000901cf.64.1723142317300; Thu, 08 Aug 2024 11:38:37 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-451c87409casm15296671cf.49.2024.08.08.11.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 11:38:36 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH 13 backport] c++: local class memfn synth from uneval context [PR113063] Date: Thu, 8 Aug 2024 14:38:35 -0400 Message-ID: <20240808183835.2538214-1-ppalka@redhat.com> X-Mailer: git-send-email 2.46.0.39.g891ee3b9db MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 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 Bootstrap and regtest in progress, does this look OK for the 13 branch if successful? -- >8 -- This is essentially a narrow backport of r14-6724-gfced59166f95e9 that uses cp_evaluated instead of maybe_push_to_top_level to clear cp_unevaluated_operand within synthesize_method, which turns out is sufficient to also fix the 13.3 regression PR116289 (whose immediate cause is the libstdc++ change r13-7739-gd919309679334a triggering a consteval bug). PR c++/113063 PR c++/116289 gcc/cp/ChangeLog: * method.cc (synthesize_method): Use cp_evaluated. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-synth16.C: New test. * g++.dg/cpp2a/spaceship-synth16a.C: New test. --- gcc/cp/method.cc | 1 + gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C | 13 +++++++++++++ gcc/testsuite/g++.dg/cpp2a/spaceship-synth16a.C | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth16a.C diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc index 9fd5567e97f..09ea6d732df 100644 --- a/gcc/cp/method.cc +++ b/gcc/cp/method.cc @@ -1797,6 +1797,7 @@ synthesize_method (tree fndecl) it now. */ push_deferring_access_checks (dk_no_deferred); + cp_evaluated ev; if (! context) push_to_top_level (); else if (nested) diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C new file mode 100644 index 00000000000..37a183de0f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C @@ -0,0 +1,13 @@ +// PR c++/113063 +// { dg-do link { target c++20 } } + +#include + +int main() { + struct X { + auto operator<=>(const X&) const = default; + }; + X x; + static_assert(noexcept(x <=> x)); + x <=> x; +} diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth16a.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth16a.C new file mode 100644 index 00000000000..fb14d487e23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth16a.C @@ -0,0 +1,16 @@ +// PR c++/116289 +// PR c++/113063 +// { dg-do link { target c++20 } } +// A version of spaceship-synth16.C where the local class isn't empty. + +#include + +int main() { + struct X { + int x = 0; + auto operator<=>(const X&) const = default; + }; + X x; + static_assert(noexcept(x <=> x)); + x <=> x; +}