| 1 |
// RUN: %clang_cc1 -std=c++20 -verify %s |
| 2 |
|
| 3 |
struct A { |
| 4 |
bool operator!=(const A&) const = default; // expected-warning {{explicitly defaulted equality comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 5 |
// expected-note@-1 {{defaulted 'operator!=' is implicitly deleted because there is no viable 'operator==' for 'A'}} |
| 6 |
}; |
| 7 |
|
| 8 |
struct A2 { |
| 9 |
struct E {}; |
| 10 |
E e; |
| 11 |
bool operator==(const A2&) const = default; // expected-warning {{explicitly defaulted equality comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 12 |
// expected-note@-2 {{defaulted 'operator==' is implicitly deleted because there is no viable 'operator==' for member 'e'}} |
| 13 |
}; |
| 14 |
|
| 15 |
|
| 16 |
struct Q {}; |
| 17 |
bool operator!=(Q, Q); // expected-note {{defaulted 'operator!=' is implicitly deleted because this non-rewritten comparison function would be the best match for the comparison}} |
| 18 |
struct B { |
| 19 |
operator Q() const; |
| 20 |
bool operator!=(const B&) const = default; // expected-warning {{explicitly defaulted equality comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 21 |
}; |
| 22 |
|
| 23 |
struct R {}; |
| 24 |
bool operator==(R, R); |
| 25 |
struct B2 { |
| 26 |
operator R() const; |
| 27 |
bool operator!=(const B2&) const = default; // OK! Converts to use rewritten R comparison. |
| 28 |
}; |
| 29 |
|
| 30 |
struct C { |
| 31 |
operator int() const; // expected-note {{defaulted 'operator!=' is implicitly deleted because a builtin comparison function using this conversion would be the best match for the comparison}} |
| 32 |
bool operator!=(const C&) const = default; // expected-warning {{explicitly defaulted equality comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 33 |
}; |
| 34 |
|
| 35 |
struct D { |
| 36 |
bool operator<(const D&) const = default; // expected-warning {{explicitly defaulted relational comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 37 |
// expected-note@-1 {{defaulted 'operator<' is implicitly deleted because there is no viable three-way comparison function for 'D'}} |
| 38 |
}; |
| 39 |
|
| 40 |
bool operator<(Q, Q); // expected-note {{defaulted 'operator<' is implicitly deleted because this non-rewritten comparison function would be the best match for the comparison}} |
| 41 |
struct E { |
| 42 |
operator Q() const; |
| 43 |
bool operator<(const E&) const = default; // expected-warning {{explicitly defaulted relational comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 44 |
}; |
| 45 |
|
| 46 |
int operator<=>(R, R); |
| 47 |
struct E2 { |
| 48 |
operator R() const; |
| 49 |
bool operator<(const E2&) const = default; |
| 50 |
}; |
| 51 |
|
| 52 |
struct F { |
| 53 |
operator int() const; // expected-note {{defaulted 'operator<' is implicitly deleted because a builtin comparison function using this conversion would be the best match for the comparison}} |
| 54 |
bool operator<(const F&) const = default; // expected-warning {{explicitly defaulted relational comparison operator is implicitly deleted}} expected-note{{replace 'default'}} |
| 55 |
}; |