From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: conditional noexcept-spec on defaulted comparison op [PR96242]
Date: Thu, 3 Feb 2022 15:26:52 -0500 [thread overview]
Message-ID: <152576a5-c950-b21c-edfd-a15a7b0305b3@redhat.com> (raw)
In-Reply-To: <20220203195838.409426-1-ppalka@redhat.com>
On 2/3/22 14:58, Patrick Palka wrote:
> When synthesizing a defaulted comparison op from
> maybe_instantiate_noexcept, we seem to be forgetting to instantiate the
> noexcept-spec afterwards.
Hmm, there shouldn't be any need to instantiate the noexcept-spec
afterwards, it should have been set by ~comp_info.
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk and perhaps 11?
>
> PR c++/96242
>
> gcc/cp/ChangeLog:
>
> * pt.cc (maybe_instantiate_noexcept): Keep going after
> successfully synthesizing a DECL_MAYBE_DELETED fn.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/cpp2a/spaceship-synth15.C: New test.
> ---
> gcc/cp/pt.cc | 3 ++-
> .../g++.dg/cpp2a/spaceship-synth15.C | 22 +++++++++++++++++++
> 2 files changed, 24 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C
>
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 6dd64101ced..03345ed3ed3 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -25986,7 +25986,8 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain)
> ++function_depth;
> maybe_synthesize_method (fn);
> --function_depth;
> - return !DECL_MAYBE_DELETED (fn);
> + if (DECL_MAYBE_DELETED (fn))
> + return false;
> }
>
> tree fntype = TREE_TYPE (fn);
> diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C
> new file mode 100644
> index 00000000000..00ea6c10474
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C
> @@ -0,0 +1,22 @@
> +// PR c++/96242
> +// { dg-do compile { target c++20 } }
> +
> +#include <compare>
> +
> +template<bool B>
> +struct X {
> + auto operator<=>(const X&) const noexcept(B) = default;
> + bool operator==(const X&) const noexcept(!B) = default;
> +};
> +
> +X<true> x_t;
> +static_assert(noexcept(x_t <=> x_t));
> +static_assert(noexcept(x_t < x_t));
> +static_assert(!noexcept(x_t == x_t));
> +static_assert(!noexcept(x_t != x_t));
> +
> +X<false> x_f;
> +static_assert(!noexcept(x_f <=> x_f));
> +static_assert(!noexcept(x_f < x_f));
> +static_assert(noexcept(x_f == x_f));
> +static_assert(noexcept(x_f != x_f));
next prev parent reply other threads:[~2022-02-03 20:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 19:58 Patrick Palka
2022-02-03 20:26 ` Jason Merrill [this message]
2022-02-03 21:06 ` Patrick Palka
2022-02-03 21:38 ` Jason Merrill
2022-02-04 17:04 ` Patrick Palka
2022-02-04 22:00 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=152576a5-c950-b21c-edfd-a15a7b0305b3@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).