summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/pseudo-destructors.cpp
blob: 0850c44a36f9dc68f9fd31028400fd59e0b1ce83 (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
// 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}}
}
OpenPOWER on IntegriCloud