public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1784] c++: defaulted friend op== [PR106361] Date: Thu, 21 Jul 2022 21:21:54 +0000 (GMT) [thread overview] Message-ID: <20220721212154.60A6A3834E6A@sourceware.org> (raw) https://gcc.gnu.org/g:28be481cf47d52af8b11972d2394226bbaf87867 commit r13-1784-g28be481cf47d52af8b11972d2394226bbaf87867 Author: Jason Merrill <jason@redhat.com> Date: Wed Jul 20 20:00:58 2022 -0400 c++: defaulted friend op== [PR106361] Now non-member functions can be defaulted, so this assert is wrong. move_signature_fn_p already checks for ctor or op=. PR c++/106361 gcc/cp/ChangeLog: * decl.cc (move_fn_p): Remove assert. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-eq14.C: New test. Diff: --- gcc/cp/decl.cc | 2 -- gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index aa6cf3c6c2e..70ad681467e 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -15022,8 +15022,6 @@ copy_fn_p (const_tree d) bool move_fn_p (const_tree d) { - gcc_assert (DECL_FUNCTION_MEMBER_P (d)); - if (cxx_dialect == cxx98) /* There are no move constructors if we are in C++98 mode. */ return false; diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C new file mode 100644 index 00000000000..896e5232bf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C @@ -0,0 +1,17 @@ +// PR c++/106361 +// { dg-do compile { target c++20 } } + +struct foo { + int x; +}; + +struct bar { + foo f; // { dg-error "operator==" } + friend bool operator==(const bar& a, const bar& b); +}; + +bool operator==(const bar& a, const bar& b) = default; + +int main() { + return bar{} == bar{}; // { dg-error "deleted" } +}
reply other threads:[~2022-07-21 21:21 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220721212154.60A6A3834E6A@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).