From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8F58B3858C78 for ; Mon, 18 Dec 2023 21:48:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F58B3858C78 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 8F58B3858C78 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=1702936094; cv=none; b=nqd8U8FDdqYT+qa5o7lnvWeKsuG7iBRu4a48uJYDTM+1maQVpFid2KeDq3RhuTbBJgPnSwU2pCYU7plAeFksvk9gY1B0gIu3ym/XaoZPqcQqJmUeON/eUd0dcYi5uwGFifG5CjDGFMNCwcUioF4QaglR1MNL1U1hejjc8ICNU8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702936094; c=relaxed/simple; bh=eMVkXe3JY543HD5JM5BPMUaj+JJ9fHRK6pDWw6pmmX0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Ys8u+hyK+7NrnFy8G8zn3dc8w+y0rOaOdaMSSYqkOdjA+MDh8hMIAiolfl2bqJarVeY/3FrHigLOYMOzQYjYkk2FAOXzu6SMKIMPAPE4QLJBnTnaRA+4/CxRDN2Lf4yx2rPNSVF/7ojSoPMgV11cWWK38HOpzBiEmygKhID6F/Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702936088; 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: in-reply-to:in-reply-to:references:references; bh=06Tp4OJflLoVqlp91xEo5ZgF9YU8xH7EEKj8uHkHW/0=; b=B+pIyqTGBTnaJW9XKvEQksPzvHWqbv48xagkYu3tL3SDWJk1/jj0Rl3H0t1xXfxmOcGUeu MJjJNace56vNxeHxDyytzEXBj3dm//XLAAO9BaRGM8AwUfPM+IJdy/zTUh8LOQp8gRUYCl OsFuDjHvg8aQiI9L/NdtYtpWWoHpYaA= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-chnPIW-iMaaUrPn6zukbsg-1; Mon, 18 Dec 2023 16:48:06 -0500 X-MC-Unique: chnPIW-iMaaUrPn6zukbsg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67ee7d18256so56742266d6.0 for ; Mon, 18 Dec 2023 13:48:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702936086; x=1703540886; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=06Tp4OJflLoVqlp91xEo5ZgF9YU8xH7EEKj8uHkHW/0=; b=jtI46DLLEBCLy7c0bqr3BrETnUPuxiN8uaYFOUnbWa83icKTMbr3kKKoKnSKPZva2E JpkaStqSSJw4gYz9NHdo6/seP32A4yVRC7s19DqfbaEpm0Fc7mslF6GRljwJcrp9vtK6 DFDFDEpQOXhaGVk2x8BxAWnYKlBAlKUO6fi74OPZmxpB8R2RaBwn3uPsCIoCpm99Pdeo cjphLdmCAbhof8jtCrymFQl2/935FouaqMRPwYK9pw8vvV+vuAFRGB0GQ494lL/3v3ot fxI9lD5i7Fl5+1MEjiE00wTRBa1O6sWOu0nX4+ziiiP5nl5pSHpppQ9gAk3xG02fSrb2 K4og== X-Gm-Message-State: AOJu0YzIlKVkuuesUmGPV8rauZhhROLUgnfucuamrqdvqlZJGAiyxGX0 Ku+08smwmt5T3hi4WZFlkZmTo4y/1YkGy/cwe4UqxQcNGQTKIG6qqtk9ivA3ZJN1V5YWbTMwsj+ /d+KT2l339STYU1BzfEfQB1yKqA== X-Received: by 2002:a05:6214:1c4c:b0:67f:2680:81f2 with SMTP id if12-20020a0562141c4c00b0067f268081f2mr7453244qvb.77.1702936086188; Mon, 18 Dec 2023 13:48:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGENKuNqIBxCAAso0JD58cDFh4tYDG8rFMJ3wphKGfVPVGFIkxJ9nYppGf+hygkf5+orxumg== X-Received: by 2002:a05:6214:1c4c:b0:67f:2680:81f2 with SMTP id if12-20020a0562141c4c00b0067f268081f2mr7453238qvb.77.1702936085942; Mon, 18 Dec 2023 13:48:05 -0800 (PST) Received: from [192.168.1.146] (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 i5-20020a056214030500b0067f523dc182sm612892qvu.126.2023.12.18.13.48.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 13:48:05 -0800 (PST) Message-ID: <78efb8a5-35f6-4986-b4e7-fb5d8bea53d3@redhat.com> Date: Mon, 18 Dec 2023 16:48:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: local class memfn synth from uneval context [PR113063] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20231218195013.1241371-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20231218195013.1241371-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.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_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/18/23 14:50, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > -- >8 -- > > Here we first use and therefore synthesize the local class operator<=> > from an unevaluated context, which inadvertently affects synthesization > by causing functions used within the definition (such as the copy > constructor of std::strong_ordering) to not get marked as odr-used. > > This patch fixes this by using maybe_push_to_top_level in synthesize_method > which ensures that cp_unevaluated_operand is cleared even in the > function-local case. > > PR c++/113063 > > gcc/cp/ChangeLog: > > * method.cc (synthesize_method): Use maybe_push_to_top_level > and maybe_pop_from_top_level. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/spaceship-synth16.C: New test. > --- > gcc/cp/method.cc | 12 ++---------- > gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C | 13 +++++++++++++ > 2 files changed, 15 insertions(+), 10 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C > > diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc > index 26e6eb79946..f645066077f 100644 > --- a/gcc/cp/method.cc > +++ b/gcc/cp/method.cc > @@ -1770,8 +1770,6 @@ decl_remember_implicit_trigger_p (tree decl) > void > synthesize_method (tree fndecl) > { > - bool nested = (current_function_decl != NULL_TREE); > - tree context = decl_function_context (fndecl); > bool need_body = true; > tree stmt; > location_t save_input_location = input_location; > @@ -1795,10 +1793,7 @@ synthesize_method (tree fndecl) > it now. */ > push_deferring_access_checks (dk_no_deferred); > > - if (! context) > - push_to_top_level (); > - else if (nested) > - push_function_context (); > + bool push_to_top = maybe_push_to_top_level (fndecl); > > input_location = DECL_SOURCE_LOCATION (fndecl); > > @@ -1843,10 +1838,7 @@ synthesize_method (tree fndecl) > > input_location = save_input_location; > > - if (! context) > - pop_from_top_level (); > - else if (nested) > - pop_function_context (); > + maybe_pop_from_top_level (push_to_top); > > pop_deferring_access_checks (); > > 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..8e59f7d2e46 > --- /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)); > + static_cast(x <=> x); > +}