diff options
author | Jason Merrill <jason@redhat.com> | 2022-07-20 20:00:58 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-07-21 17:22:57 -0400 |
commit | 707bc64fbeecf8a10f7aad103534b6999e9d190c (patch) | |
tree | 2aeaad7d96699e9ee837a6f1070fd993bd9d6058 /gcc | |
parent | a074ae297d5dbd69e03c6c30f9cb7720685fdb62 (diff) |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/decl.cc | 2 | ||||
-rw-r--r-- | 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 f972bd50e75..9f78c500a15 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -15016,8 +15016,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" } +} |