Fariborz Jahanian | b54ccb2 | 2009-09-11 21:44:33 +0000 | [diff] [blame^] | 1 | // RUN: clang-cc -fsyntax-only -verify -std=c++0x %s |
| 2 | |
| 3 | // Test1 |
| 4 | struct B { |
| 5 | operator char *(); |
| 6 | }; |
| 7 | |
| 8 | struct D : B { |
| 9 | operator int *(); |
| 10 | }; |
| 11 | |
| 12 | void f (D d) |
| 13 | { |
| 14 | delete d; // expected-error {{cannot delete expression of type 'struct D'}} |
| 15 | } |
| 16 | |
| 17 | // Test2 |
| 18 | struct B1 { |
| 19 | operator int *(); |
| 20 | }; |
| 21 | |
| 22 | struct D1 : B1 { |
| 23 | operator int *(); |
| 24 | }; |
| 25 | |
| 26 | void f1 (D1 d) |
| 27 | { |
| 28 | delete d; |
| 29 | } |
| 30 | |
| 31 | // Test3 |
| 32 | struct B2 { |
| 33 | operator const int *(); |
| 34 | }; |
| 35 | |
| 36 | struct D2 : B2 { |
| 37 | operator int *(); |
| 38 | }; |
| 39 | |
| 40 | void f2 (D2 d) |
| 41 | { |
| 42 | delete d; // expected-error {{cannot delete expression of type 'struct D2'}} |
| 43 | } |
| 44 | |
| 45 | // Test4 |
| 46 | |
| 47 | struct B3 { |
| 48 | operator const int *(); |
| 49 | }; |
| 50 | |
| 51 | struct A3 { |
| 52 | operator const int *(); |
| 53 | }; |
| 54 | |
| 55 | struct D3 : A3, B3 { |
| 56 | }; |
| 57 | |
| 58 | void f3 (D3 d) |
| 59 | { |
| 60 | delete d; // expected-error {{cannot delete expression of type 'struct D3'}} |
| 61 | } |
| 62 | |
| 63 | // Test5 |
| 64 | struct X { |
| 65 | operator int(); |
| 66 | operator int*(); |
| 67 | }; |
| 68 | |
| 69 | void f4(X x) { delete x; delete x; } |
| 70 | |
| 71 | // Test6 |
| 72 | |
| 73 | struct X1 { |
| 74 | operator int(); |
| 75 | operator int*(); |
| 76 | template<typename T> operator T*() const; // converts to any pointer! |
| 77 | }; |
| 78 | |
| 79 | void f5(X1 x) { delete x; } // FIXME. May have to issue error here too. |
| 80 | |
| 81 | |
| 82 | |
| 83 | |