Douglas Gregor | 3ef6c97 | 2008-11-07 20:08:42 +0000 | [diff] [blame^] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | class X { |
| 3 | public: |
| 4 | operator bool(); |
| 5 | operator int() const; |
| 6 | }; |
| 7 | |
| 8 | operator int(); // expected-error{{conversion function must be a non-static member function}} |
| 9 | |
| 10 | typedef int func_type(int); |
| 11 | typedef int array_type[10]; |
| 12 | |
| 13 | class Y { |
| 14 | public: |
| 15 | void operator bool(int, ...) const; // expected-error{{conversion function cannot have a return type}} \ |
| 16 | // expected-error{{conversion function cannot have any parameters}} \ |
| 17 | // expected-error{{conversion function cannot be variadic}} |
| 18 | operator func_type(); // expected-error{{conversion function cannot convert to a function type}} |
| 19 | operator array_type(); // expected-error{{conversion function cannot convert to an array type}} |
| 20 | }; |
| 21 | |
| 22 | |
| 23 | typedef int INT; |
| 24 | typedef INT* INT_PTR; |
| 25 | |
| 26 | class Z { |
| 27 | operator int(); // expected-error{{previous declaration is here}} |
| 28 | operator int**(); // expected-error{{previous declaration is here}} |
| 29 | |
| 30 | operator INT(); // expected-error{{conversion function cannot be redeclared}} |
| 31 | operator INT_PTR*(); // expected-error{{conversion function cannot be redeclared}} |
| 32 | }; |
| 33 | |
| 34 | |
| 35 | class A { }; |
| 36 | |
| 37 | class B : public A { |
| 38 | public: |
| 39 | operator A&() const; // expected-warning{{conversion function converting 'class B' to its base class 'class A' will never be used}} |
| 40 | operator const void() const; // expected-warning{{conversion function converting 'class B' to 'void const' will never be used}} |
| 41 | operator const B(); // expected-warning{{conversion function converting 'class B' to itself will never be used}} |
| 42 | }; |