1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2*67e74705SXin Li struct A {};
3*67e74705SXin Li
4*67e74705SXin Li enum Foo { F };
5*67e74705SXin Li typedef Foo Bar; // expected-note{{type 'Bar' (aka 'Foo') is declared here}}
6*67e74705SXin Li
7*67e74705SXin Li typedef int Integer;
8*67e74705SXin Li typedef double Double;
9*67e74705SXin Li
10*67e74705SXin Li void g();
11*67e74705SXin Li
12*67e74705SXin Li namespace N {
13*67e74705SXin Li typedef Foo Wibble;
14*67e74705SXin Li typedef int OtherInteger;
15*67e74705SXin Li }
16*67e74705SXin Li
17*67e74705SXin Li template <typename T>
cv_test(const volatile T * cvt)18*67e74705SXin Li void cv_test(const volatile T* cvt) {
19*67e74705SXin Li cvt->T::~T(); // no-warning
20*67e74705SXin Li }
21*67e74705SXin Li
f(A * a,Foo * f,int * i,double * d,int ii)22*67e74705SXin Li void f(A* a, Foo *f, int *i, double *d, int ii) {
23*67e74705SXin Li a->~A();
24*67e74705SXin Li a->A::~A();
25*67e74705SXin Li
26*67e74705SXin Li a->~foo(); // expected-error{{identifier 'foo' in object destruction expression does not name a type}}
27*67e74705SXin Li
28*67e74705SXin Li a->~Bar(); // expected-error{{destructor type 'Bar' (aka 'Foo') in object destruction expression does not match the type 'A' of the object being destroyed}}
29*67e74705SXin Li
30*67e74705SXin Li f->~Bar();
31*67e74705SXin Li f->~Foo();
32*67e74705SXin Li i->~Bar(); // expected-error{{does not match}}
33*67e74705SXin Li
34*67e74705SXin Li g().~Bar(); // expected-error{{non-scalar}}
35*67e74705SXin Li
36*67e74705SXin Li f->::~Bar();
37*67e74705SXin Li f->N::~Wibble(); // FIXME: technically, Wibble isn't a class-name
38*67e74705SXin Li
39*67e74705SXin Li f->::~Bar(17, 42); // expected-error{{cannot have any arguments}}
40*67e74705SXin Li
41*67e74705SXin Li i->~Integer();
42*67e74705SXin Li i->Integer::~Integer();
43*67e74705SXin Li i->N::~OtherInteger();
44*67e74705SXin Li i->N::OtherInteger::~OtherInteger();
45*67e74705SXin Li i->N::OtherInteger::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
46*67e74705SXin Li i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
47*67e74705SXin Li 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}}
48*67e74705SXin Li
49*67e74705SXin Li ii->~Integer(); // expected-error{{member reference type 'int' is not a pointer; did you mean to use '.'?}}
50*67e74705SXin Li ii.~Integer();
51*67e74705SXin Li
52*67e74705SXin Li cv_test(a);
53*67e74705SXin Li cv_test(f);
54*67e74705SXin Li cv_test(i);
55*67e74705SXin Li cv_test(d);
56*67e74705SXin Li }
57*67e74705SXin Li
58*67e74705SXin Li
59*67e74705SXin Li typedef int Integer;
60*67e74705SXin Li
destroy_without_call(int * ip)61*67e74705SXin Li void destroy_without_call(int *ip) {
62*67e74705SXin Li ip->~Integer; // expected-error{{reference to pseudo-destructor must be called}}
63*67e74705SXin Li }
64*67e74705SXin Li
paren_destroy_with_call(int * ip)65*67e74705SXin Li void paren_destroy_with_call(int *ip) {
66*67e74705SXin Li (ip->~Integer)();
67*67e74705SXin Li }
68*67e74705SXin Li
69*67e74705SXin Li // PR5530
70*67e74705SXin Li namespace N1 {
71*67e74705SXin Li class X0 { };
72*67e74705SXin Li }
73*67e74705SXin Li
test_X0(N1::X0 & x0)74*67e74705SXin Li void test_X0(N1::X0 &x0) {
75*67e74705SXin Li x0.~X0();
76*67e74705SXin Li }
77*67e74705SXin Li
78*67e74705SXin Li namespace PR11339 {
79*67e74705SXin Li template<class T>
destroy(T * p)80*67e74705SXin Li void destroy(T* p) {
81*67e74705SXin Li p->~T(); // ok
82*67e74705SXin Li p->~oops(); // expected-error{{expected the class name after '~' to name a destructor}}
83*67e74705SXin Li }
84*67e74705SXin Li
85*67e74705SXin Li template void destroy(int*); // expected-note{{in instantiation of function template specialization}}
86*67e74705SXin Li }
87*67e74705SXin Li
88*67e74705SXin Li template<typename T> using Id = T;
AliasTemplate(int * p)89*67e74705SXin Li void AliasTemplate(int *p) {
90*67e74705SXin Li p->~Id<int>();
91*67e74705SXin Li }
92