Shih-wei Liao | f8fd82b | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | struct X { |
| 3 | X(); |
| 4 | X(int); |
| 5 | }; |
| 6 | |
| 7 | X operator+(X, X); |
| 8 | X operator-(X, X) { X x; return x; } |
| 9 | |
| 10 | struct Y { |
| 11 | Y operator-() const; |
| 12 | void operator()(int x = 17) const; |
| 13 | int operator[](int); |
| 14 | |
| 15 | static int operator+(Y, Y); // expected-error{{overloaded 'operator+' cannot be a static member function}} |
| 16 | }; |
| 17 | |
| 18 | |
| 19 | void f(X x) { |
| 20 | x = operator+(x, x); |
| 21 | } |
| 22 | |
| 23 | X operator+(int, float); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}} |
| 24 | |
| 25 | X operator*(X, X = 5); // expected-error{{parameter of overloaded 'operator*' cannot have a default argument}} |
| 26 | |
| 27 | X operator/(X, X, ...); // expected-error{{overloaded 'operator/' cannot be variadic}} |
| 28 | |
| 29 | X operator%(Y); // expected-error{{overloaded 'operator%' must be a binary operator (has 1 parameter)}} |
| 30 | |
| 31 | void operator()(Y&, int, int); // expected-error{{overloaded 'operator()' must be a non-static member function}} |
| 32 | |
| 33 | typedef int INT; |
| 34 | typedef float FLOAT; |
| 35 | Y& operator++(Y&); |
| 36 | Y operator++(Y&, INT); |
| 37 | X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}} |
| 38 | |
| 39 | int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}} |
| 40 | |
| 41 | namespace PR6238 { |
| 42 | static struct { |
| 43 | void operator()(); |
| 44 | } plus; |
| 45 | } |