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:
parent
df118d7ba1
commit
28be481cf4
@ -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;
|
||||
|
17
gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C
Normal file
17
gcc/testsuite/g++.dg/cpp2a/spaceship-eq14.C
Normal 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" }
|
||||
}
|
Loading…
Reference in New Issue
Block a user