summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/class/class.compare/class.compare.default/p1.cpp')
-rw-r--r--clang/test/CXX/class/class.compare/class.compare.default/p1.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a73b3487076..1a0ccc91741 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -std=c++2a -verify %s
struct B {};
-bool operator==(const B&, const B&) = default; // expected-error {{equality comparison operator can only be defaulted in a class definition}}
+bool operator==(const B&, const B&) = default; // expected-error {{equality comparison operator can only be defaulted in a class definition}} expected-note {{candidate}}
bool operator<=>(const B&, const B&) = default; // expected-error {{three-way comparison operator can only be defaulted in a class definition}}
template<typename T = void>
@@ -9,18 +9,19 @@ template<typename T = void>
struct A {
friend bool operator==(const A&, const A&) = default;
- friend bool operator!=(const A&, const B&) = default; // expected-error {{invalid parameter type for defaulted equality comparison}}
+ friend bool operator!=(const A&, const B&) = default; // expected-error {{invalid parameter type for defaulted equality comparison operator; found 'const B &', expected 'A' or 'const A &'}}
friend bool operator!=(const B&, const B&) = default; // expected-error {{invalid parameter type for defaulted equality comparison}}
friend bool operator<(const A&, const A&);
friend bool operator<(const B&, const B&) = default; // expected-error {{invalid parameter type for defaulted relational comparison}}
- friend bool operator>(A, A) = default; // expected-error {{invalid parameter type for defaulted relational comparison}}
+ friend bool operator>(A, A) = default; // expected-warning {{implicitly deleted}}
bool operator<(const A&) const;
bool operator<=(const A&) const = default;
bool operator==(const A&) const volatile && = default; // surprisingly, OK
bool operator<=>(const A&) = default; // expected-error {{defaulted member three-way comparison operator must be const-qualified}}
- bool operator>=(const B&) const = default; // expected-error {{invalid parameter type for defaulted relational comparison}}
+ bool operator>=(const B&) const = default; // expected-error-re {{invalid parameter type for defaulted relational comparison operator; found 'const B &', expected 'const A &'{{$}}}}
static bool operator>(const B&) = default; // expected-error {{overloaded 'operator>' cannot be a static member function}}
+ friend bool operator>(A, const A&) = default; // expected-error {{must have the same type}} expected-note {{would be the best match}}
template<typename T = void>
friend bool operator==(const A&, const A&) = default; // expected-error {{comparison operator template cannot be defaulted}}
@@ -120,3 +121,14 @@ namespace LookupContext {
}
}
}
+
+namespace P1946 {
+ struct A {
+ friend bool operator==(A &, A &); // expected-note {{would lose const qualifier}}
+ };
+ struct B {
+ A a; // expected-note {{no viable comparison}}
+ friend bool operator==(B, B) = default; // ok
+ friend bool operator==(const B&, const B&) = default; // expected-warning {{deleted}}
+ };
+}
OpenPOWER on IntegriCloud