public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10160] c++: defaulted friend op== [PR106361]
@ 2022-07-22  5:40 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-07-22  5:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1503d946c06e2005c860f56231d2ea582a8a340f

commit r11-10160-g1503d946c06e2005c860f56231d2ea582a8a340f
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.c (move_fn_p): Remove assert.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/spaceship-eq14.C: New test.

Diff:
---
 gcc/cp/decl.c                               |  2 --
 gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 052378a2e75..514d4c1bc20 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14689,8 +14689,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" }
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-22  5:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22  5:40 [gcc r11-10160] c++: defaulted friend op== [PR106361] Jason Merrill

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).