blob: 6806c24a84ebafeb0177ea2ac69ceeab75277122 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanianc87efbd2009-08-25 16:37:49 +00002
3template<typename A> class s0 {
4
5 template<typename B> class s1 : public s0<A> {
6 ~s1() {}
7 s0<A> ms0;
8 };
9
10};
11
Douglas Gregor31658df2009-11-20 19:58:21 +000012struct Incomplete;
Fariborz Jahanianc87efbd2009-08-25 16:37:49 +000013
Douglas Gregor31658df2009-11-20 19:58:21 +000014template<typename T>
15void destroy_me(T me) {
16 me.~T();
17}
18
19template void destroy_me(Incomplete*);
Douglas Gregor124b8782010-02-16 19:09:40 +000020
21namespace PR6152 {
22 template<typename T> struct X { void f(); };
23 template<typename T> struct Y { };
24 template<typename T>
25 void X<T>::f() {
26 Y<T> *y;
27 y->template Y<T>::~Y();
Douglas Gregora2e7dd22010-02-25 01:56:36 +000028 y->template Y<T>::~Y<T>();
29 y->~Y();
Douglas Gregor124b8782010-02-16 19:09:40 +000030 }
31
32 template struct X<int>;
33}
34
Douglas Gregor20b3c9d2010-04-23 04:51:46 +000035namespace cvquals {
36 template<typename T>
37 void f(int *ptr) {
38 ptr->~T();
39 }
40
41 template void f<const volatile int>(int *);
42}
Douglas Gregor9f716e42010-05-27 15:25:59 +000043
44namespace PR7239 {
45 template<class E> class A { };
46 class B {
47 void f() {
48 A<int>* x;
49 x->A<int>::~A<int>();
50 }
51 };
52}
Douglas Gregorcb710a42011-03-04 22:45:55 +000053
54namespace PR7904 {
55 struct Foo {
56 template <int i> ~Foo() {} // expected-error{{destructor cannot be declared as a template}}
57 };
58 Foo f;
59}
Douglas Gregor303b96f2013-03-08 21:25:01 +000060
61namespace rdar13140795 {
62 template <class T> class shared_ptr {};
63
64 template <typename T> struct Marshal {
65 static int gc();
66 };
67
68
69 template <typename T> int Marshal<T>::gc() {
70 shared_ptr<T> *x;
71 x->template shared_ptr<T>::~shared_ptr();
72 return 0;
73 }
74
75 void test() {
76 Marshal<int>::gc();
77 }
78}