1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
9 X
operator-(X
, X
) { X x
; return x
; }
13 void operator()(int x
= 17) const;
16 static int operator+(Y
, Y
); // expected-error{{overloaded 'operator+' cannot be a static member function}}
24 X
operator+(int, float); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}}
26 X
operator*(X
, X
= 5); // expected-error{{parameter of overloaded 'operator*' cannot have a default argument}}
28 X
operator/(X
, X
, ...); // expected-error{{overloaded 'operator/' cannot be variadic}}
30 X
operator%(Y
); // expected-error{{overloaded 'operator%' must be a binary operator (has 1 parameter)}}
32 void operator()(Y
&, int, int); // expected-error{{overloaded 'operator()' must be a non-static member function}}
37 Y
operator++(Y
&, INT
);
38 X
operator++(X
&, FLOAT
); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}}
40 int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
49 operator int; // expected-error{{'operator int' cannot be the name of a variable or data member}}
50 int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
55 static void operator()(int& i
) { ++i
; } // expected-warning{{is a C++23 extension}}
65 E
& operator=(const E
& rhs
, ...); // expected-error{{overloaded 'operator=' cannot be variadic}}
66 E
& operator+=(const E
& rhs
, ...); // expected-error{{overloaded 'operator+=' cannot be variadic}}
69 void operator+(E
, ...) {} // expected-error{{overloaded 'operator+' cannot be variadic}}
70 void operator-(E
, ...) {} // expected-error{{overloaded 'operator-' cannot be variadic}}
71 void operator*(E
, ...) {} // expected-error{{overloaded 'operator*' cannot be variadic}}
72 void operator/(E
, ...) {} // expected-error{{overloaded 'operator/' must be a binary operator}}
73 void operator/(E
, E
, ...) {} // expected-error{{overloaded 'operator/' cannot be variadic}}
74 void operator%(E
, ...) {} // expected-error{{overloaded 'operator%' must be a binary operator}}
75 void operator%(E
, E
, ...) {} // expected-error{{overloaded 'operator%' cannot be variadic}}
76 E
& operator++(E
&, ...); // expected-error{{overloaded 'operator++' cannot be variadic}}
77 E
& operator--(E
&, ...); // expected-error{{overloaded 'operator--' cannot be variadic}}
78 bool operator<(const E
& lhs
, ...); // expected-error{{overloaded 'operator<' must be a binary operator}}
79 bool operator<(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
80 bool operator>(const E
& lhs
, ...); // expected-error{{overloaded 'operator>' must be a binary operator}}
81 bool operator>(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
82 bool operator>=(const E
& lhs
, ...); // expected-error{{overloaded 'operator>=' must be a binary operator}}
83 bool operator>=(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
84 bool operator<=(const E
& lhs
, ...); // expected-error{{overloaded 'operator<=' must be a binary operator}}
85 bool operator<=(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
86 bool operator==(const E
& lhs
, ...); // expected-error{{overloaded 'operator==' must be a binary operator}}
87 bool operator==(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
88 bool operator!=(const E
& lhs
, ...); // expected-error{{overloaded 'operator!=' must be a binary operator}}
89 bool operator!=(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
90 bool operator&&(const E
& lhs
, ...); // expected-error{{overloaded 'operator&&' must be a binary operator}}
91 bool operator&&(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
92 bool operator||(const E
& lhs
, ...); // expected-error{{overloaded 'operator||' must be a binary operator}}
93 bool operator||(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
94 bool operator>>(const E
& lhs
, ...); // expected-error{{overloaded 'operator>>' must be a binary operator}}
95 bool operator>>(const E
& lhs
, const E
& rhs
, ...); // expected-error{{cannot be variadic}}
96 bool operator&(const E
& lhs
, ...); // expected-error{{cannot be variadic}}
97 #if __cplusplus >= 202002L
98 auto operator<=>(const E
& lhs
, ...); // expected-error{{overloaded 'operator<=>' must be a binary operator}}
106 ++E(); // expected-error{{cannot increment value of type 'E'}}
107 --E(); // expected-error{{cannot decrement value of type 'E'}}
114 #if __cplusplus >= 202002L