summaryrefslogtreecommitdiff
path: root/test/SemaCXX/pseudo-destructors.cpp
blob: 8f69def9fd4f1d752665532c34a4510b106b1798 (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
// RUN: clang-cc -fsyntax-only -verify %s
struct A {};

enum Foo { F };
typedef Foo Bar;

typedef int Integer;

void g();

namespace N {
  typedef Foo Wibble;
}

void f(A* a, Foo *f, int *i) {
  a->~A();
  a->A::~A();
  
  a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}}
  
  // FIXME: the type printed below isn't wonderful
  a->~Bar(); // expected-error{{no member named}}
  
  f->~Bar();
  f->~Foo();
  i->~Bar(); // expected-error{{does not match}}
  
  g().~Bar(); // expected-error{{non-scalar}}
  
  f->::~Bar();
  f->N::~Wibble();
  
  f->::~Bar(17, 42); // expected-error{{cannot have any arguments}}
}

typedef int Integer;

void destroy_without_call(int *ip) {
  ip->~Integer; // expected-error{{called immediately}}
}

// PR5530
namespace N1 {
  class X0 { };
}

void test_X0(N1::X0 &x0) {
  x0.~X0();
}