aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-07-20 20:00:58 -0400
committerJason Merrill <jason@redhat.com>2022-07-21 17:21:22 -0400
commit28be481cf47d52af8b11972d2394226bbaf87867 (patch)
tree9c1d440573ca8d47a9b9ae23af822b3ebbf49872
parentdf118d7ba138cacb17203d4a1b5f27730347cc77 (diff)
downloadgcc-28be481cf47d52af8b11972d2394226bbaf87867.zip
gcc-28be481cf47d52af8b11972d2394226bbaf87867.tar.gz
gcc-28be481cf47d52af8b11972d2394226bbaf87867.tar.bz2
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.
-rw-r--r--gcc/cp/decl.cc2
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C17
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index aa6cf3c..70ad681 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 0000000..896e523
--- /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" }
+}