aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/conversion-delete-expr.cpp
blob: bb79fea39f1ca9bf7d22e618ca2fcacf8c481e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s

// Test1
struct B {
  operator char *();
};

struct D : B {
  operator int *();
};

void f (D d)
{
   delete d; // expected-error {{cannot delete expression of type 'struct D'}}
}

// Test2
struct B1 {
  operator int *();
};

struct D1 : B1 {
  operator int *();
};

void f1 (D1 d)
{
   delete d;
}

// Test3
struct B2 {
  operator const int *();
};

struct D2 : B2 {
  operator int *();
};

void f2 (D2 d)
{
   delete d; // expected-error {{cannot delete expression of type 'struct D2'}}
}

// Test4

struct B3 {
  operator const int *();
};

struct A3 {
  operator const int *();
};

struct D3 : A3, B3 {
};

void f3 (D3 d)
{
   delete d; // expected-error {{cannot delete expression of type 'struct D3'}}
}

// Test5
struct X {
   operator int();
   operator int*();
};

void f4(X x) { delete x; delete x; }

// Test6

struct X1 {
   operator int();
   operator int*();
   template<typename T> operator T*() const; // converts to any pointer!
};

void f5(X1 x) { delete x; } // FIXME. May have to issue error here too.