blob: 13ffe1b2005cb1afd31db79265553d889ef9294d [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;
8
9void g();
10
11namespace N {
12 typedef Foo Wibble;
13}
14
15void f(A* a, Foo *f, int *i) {
Anders Carlsson2cf738f2009-08-26 19:22:42 +000016 a->~A();
17 a->A::~A();
18
19 a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}}
Douglas Gregora71d8192009-09-04 17:36:40 +000020
Douglas Gregor124b8782010-02-16 19:09:40 +000021 // FIXME: the diagnostic below isn't wonderful
22 a->~Bar(); // expected-error{{does not name a type}}
Douglas Gregora71d8192009-09-04 17:36:40 +000023
24 f->~Bar();
25 f->~Foo();
26 i->~Bar(); // expected-error{{does not match}}
27
28 g().~Bar(); // expected-error{{non-scalar}}
29
30 f->::~Bar();
Douglas Gregor124b8782010-02-16 19:09:40 +000031 f->N::~Wibble(); // expected-error{{expected the class name after '~' to name a destructor}}
Douglas Gregora71d8192009-09-04 17:36:40 +000032
33 f->::~Bar(17, 42); // expected-error{{cannot have any arguments}}
Anders Carlsson2cf738f2009-08-26 19:22:42 +000034}
Douglas Gregora78c5c32009-09-04 18:29:40 +000035
36typedef int Integer;
37
38void destroy_without_call(int *ip) {
39 ip->~Integer; // expected-error{{called immediately}}
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000040}
Douglas Gregorf6e6fc82009-11-20 22:03:38 +000041
42// PR5530
43namespace N1 {
44 class X0 { };
45}
46
47void test_X0(N1::X0 &x0) {
48 x0.~X0();
49}