blob: 472e5b42fb29d61048539b1b366a2b5f4107b2c0 [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;
Douglas Gregor77549082010-02-24 21:29:12 +000014 typedef int OtherInteger;
Douglas Gregora71d8192009-09-04 17:36:40 +000015}
16
Douglas Gregorb10cd042010-02-21 18:36:56 +000017void f(A* a, Foo *f, int *i, double *d) {
Anders Carlsson2cf738f2009-08-26 19:22:42 +000018 a->~A();
19 a->A::~A();
20
21 a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}}
Douglas Gregora71d8192009-09-04 17:36:40 +000022
Douglas Gregor124b8782010-02-16 19:09:40 +000023 // FIXME: the diagnostic below isn't wonderful
24 a->~Bar(); // expected-error{{does not name a type}}
Douglas Gregora71d8192009-09-04 17:36:40 +000025
26 f->~Bar();
27 f->~Foo();
28 i->~Bar(); // expected-error{{does not match}}
29
30 g().~Bar(); // expected-error{{non-scalar}}
31
32 f->::~Bar();
Douglas Gregor93649fd2010-02-23 00:15:22 +000033 f->N::~Wibble(); // FIXME: technically, Wibble isn't a class-name
Douglas Gregora71d8192009-09-04 17:36:40 +000034
35 f->::~Bar(17, 42); // expected-error{{cannot have any arguments}}
Douglas Gregorb10cd042010-02-21 18:36:56 +000036
37 i->~Integer();
38 i->Integer::~Integer();
Douglas Gregor77549082010-02-24 21:29:12 +000039 i->N::~OtherInteger();
40 i->N::OtherInteger::~OtherInteger();
41 i->N::OtherInteger::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
42 i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
43 i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('Double' (aka 'double')) in pseudo-destructor expression}}
Anders Carlsson2cf738f2009-08-26 19:22:42 +000044}
Douglas Gregora78c5c32009-09-04 18:29:40 +000045
46typedef int Integer;
47
48void destroy_without_call(int *ip) {
49 ip->~Integer; // expected-error{{called immediately}}
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000050}
Douglas Gregorf6e6fc82009-11-20 22:03:38 +000051
52// PR5530
53namespace N1 {
54 class X0 { };
55}
56
57void test_X0(N1::X0 &x0) {
58 x0.~X0();
59}