blob: 3c96e54c53175f972057634fd7117dc249722d66 [file] [log] [blame]
Douglas Gregor3ef6c972008-11-07 20:08:42 +00001// RUN: clang -fsyntax-only -verify %s
2class X {
3public:
4 operator bool();
5 operator int() const;
6};
7
8operator int(); // expected-error{{conversion function must be a non-static member function}}
9
10typedef int func_type(int);
11typedef int array_type[10];
12
13class Y {
14public:
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
23typedef int INT;
24typedef INT* INT_PTR;
25
26class 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
35class A { };
36
37class B : public A {
38public:
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};