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