1 // RUN: clang-cc -fsyntax-only -verify %s
22 bool operator-(Y, Y); // expected-note{{candidate function}}
23 bool operator-(Z, Z); // expected-note{{candidate function}}
27 bool b = y - z; // expected-error{{use of overloaded operator '-' is ambiguous; candidates are:}}
31 bool operator==(Z&); // expected-note 2{{candidate function}}
36 bool operator==(A&, Z&); // expected-note 2{{candidate function}}
38 void h(A a, const A ac, Z z) {
40 a == z; // expected-error{{use of overloaded operator '==' is ambiguous; candidates are:}}
41 ac == z; // expected-error{{invalid operands to binary expression ('struct A const' and 'struct Z')}}
45 bool operator==(const B&) const;
63 // C++ [over.match.oper]p3 - enum restriction.
64 float& operator==(E1, E2);
66 void enum_test(Enum1 enum1, Enum2 enum2, E1 e1, E2 e2) {
67 float &f1 = (e1 == e2);
68 float &f2 = (enum1 == e2);
69 float &f3 = (e1 == enum2);
70 float &f4 = (enum1 == enum2); // expected-error{{non-const lvalue reference to type 'float' cannot be initialized with a temporary of type 'bool'}}
73 // PR5244 - Argument-dependent lookup would include the two operators below,
74 // which would break later assumptions and lead to a crash.
81 bool operator==(const pr5244_foo& s1, const pr5244_foo& s2);
82 bool operator==(char c, const pr5244_foo& s);
97 (void)(pr5244_BAR == quuux.quux);
103 PostInc operator++(int);
104 PostInc& operator++();
108 PostDec operator--(int);
109 PostDec& operator--();
112 void incdec_test(PostInc pi, PostDec pd) {
113 const PostInc& pi1 = pi++;
114 const PostDec& pd1 = pd--;
121 long& operator*() const volatile;
124 void test_smartptr(SmartPtr ptr, const SmartPtr cptr,
125 const volatile SmartPtr cvptr) {
133 int& operator[](int);
136 void test_arraylike(ArrayLike a) {
144 void test_smartref(SmartRef r) {
148 bool& operator,(X, Y);
150 void test_comma(X x, Y y) {
156 int& operator()(int, double = 2.71828); // expected-note{{candidate function}}
157 float& operator()(int, double, long, ...); // expected-note{{candidate function}}
159 double& operator()(float); // expected-note{{candidate function}}
163 int& operator()(int i = 0);
164 double& operator()(...) const;
167 struct DerivesCallable : public Callable {
170 void test_callable(Callable c, Callable2 c2, const Callable2& c2c,
171 DerivesCallable dc) {
173 float &fr = c(1, 3.14159, 17, 42);
175 c(); // expected-error{{no matching function for call to object of type 'struct Callable'; candidates are:}}
177 double &dr = c(1.0f);
184 double &fr3 = dc(3.14159f);
189 typedef INTREF Func1(FLOAT, double);
190 typedef float& Func2(int, double);
192 struct ConvertToFunc {
193 operator Func1*(); // expected-note{{conversion candidate of type 'INTREF (*)(FLOAT, double)'}}
194 operator Func2&(); // expected-note{{conversion candidate of type 'float &(&)(int, double)'}}
198 void test_funcptr_call(ConvertToFunc ctf) {
199 int &i1 = ctf(1.0f, 2.0);
200 float &f2 = ctf((short int)1, 1.0f);
201 ctf((long int)17, 2.0); // expected-error{{error: call to object of type 'struct ConvertToFunc' is ambiguous; candidates are:}}
210 HasMember* operator->();
214 Arrow1 operator->(); // expected-note{{candidate function}}
217 void test_arrow(Arrow1 a1, Arrow2 a2, const Arrow2 a3) {
220 a3->m; // expected-error{{no viable overloaded 'operator->'; candidate is}}
226 struct CopyCon : public CopyConBase {
227 CopyCon(const CopyConBase &Base);
229 CopyCon(const CopyConBase *Base) {
239 N::X operator+(N::X, N::X);
243 void test_X(N::X x) {
248 struct AA { bool operator!=(AA&); };
250 bool x(BB y, BB z) { return y != z; }
254 AX& operator ->(); // expected-note {{declared at}}
260 a->b = 0; // expected-error {{circular pointer delegation detected}}
264 struct CircB& operator->(); // expected-note {{declared at}}
268 struct CircC& operator->(); // expected-note {{declared at}}
271 struct CircA& operator->(); // expected-note {{declared at}}
276 a->val = 0; // expected-error {{circular pointer delegation detected}}
279 // PR5360: Arrays should lead to built-in candidates for subscript.
284 int getPriority(Register r) {
287 int usepri[LastReg + 1];
290 // PR5546: Don't generate incorrect and ambiguous overloads for multi-level
295 extern const char *const sMoveCommands[][2][2];
296 const char* a() { return sMoveCommands[X][0][0]; }
297 const char* b() { return (*(sMoveCommands+X))[0][0]; }
300 // PR5512 and its discussion
308 // DR507, this should be ambiguous, but we special-case assignment
310 // Note: DR507, this is ambiguous as specified
315 void operator +=(int&, S);
321 struct A {operator int();};