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.
This commit is contained in:
Jason Merrill 2022-07-20 20:00:58 -04:00
parent df118d7ba1
commit 28be481cf4
2 changed files with 17 additions and 2 deletions

View File

@ -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;

View File

@ -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" }
}