blob: 2cc233318ec4f9ef796952efade87b92a6fd95b9 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Anders Carlsson2cf738f2009-08-26 19:22:42 +00002struct A {};
3
4enum Foo { F };
5typedef Foo Bar;
6
Douglas Gregora71d8192009-09-04 17:36:40 +00007typedef int Integer;
Douglas Gregorb10cd042010-02-21 18:36:56 +00008typedef double Double;
Douglas Gregora71d8192009-09-04 17:36:40 +00009
10void g();
11
12namespace N {
13 typedef Foo Wibble;
14}
15
Douglas Gregorb10cd042010-02-21 18:36:56 +000016void f(A* a, Foo *f, int *i, double *d) {
Anders Carlsson2cf738f2009-08-26 19:22:42 +000017 a->~A();
18 a->A::~A();
19
20 a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}}
Douglas Gregora71d8192009-09-04 17:36:40 +000021
Douglas Gregor124b8782010-02-16 19:09:40 +000022 // FIXME: the diagnostic below isn't wonderful
23 a->~Bar(); // expected-error{{does not name a type}}
Douglas Gregora71d8192009-09-04 17:36:40 +000024
25 f->~Bar();
26 f->~Foo();
27 i->~Bar(); // expected-error{{does not match}}
28
29 g().~Bar(); // expected-error{{non-scalar}}
30
31 f->::~Bar();
Chandler Carruth5e895a82010-02-21 10:19:54 +000032 f->N::~Wibble(); // FIXME: Cannot use typedef name in destructor id.
Douglas Gregora71d8192009-09-04 17:36:40 +000033
34 f->::~Bar(17, 42); // expected-error{{cannot have any arguments}}
Douglas Gregorb10cd042010-02-21 18:36:56 +000035
36 i->~Integer();
37 i->Integer::~Integer();
38
39 i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('double') in pseudo-destructor expression}}
Anders Carlsson2cf738f2009-08-26 19:22:42 +000040}
Douglas Gregora78c5c32009-09-04 18:29:40 +000041
42typedef int Integer;
43
44void destroy_without_call(int *ip) {
45 ip->~Integer; // expected-error{{called immediately}}
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000046}
Douglas Gregorf6e6fc82009-11-20 22:03:38 +000047
48// PR5530
49namespace N1 {
50 class X0 { };
51}
52
53void test_X0(N1::X0 &x0) {
54 x0.~X0();
55}