blob: 853ba492f8e751ce3a6af1c5ab80302f811fc364 [file] [log] [blame]
Eli Friedman85641392013-08-09 23:37:05 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Fariborz Jahanian797cf622009-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 Gregore4f764f2009-11-20 19:58:21 +000012struct Incomplete;
Fariborz Jahanian797cf622009-08-25 16:37:49 +000013
Douglas Gregore4f764f2009-11-20 19:58:21 +000014template<typename T>
15void destroy_me(T me) {
16 me.~T();
17}
18
19template void destroy_me(Incomplete*);
Douglas Gregorfe17d252010-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 Gregor678f90d2010-02-25 01:56:36 +000028 y->template Y<T>::~Y<T>();
29 y->~Y();
Douglas Gregorfe17d252010-02-16 19:09:40 +000030 }
31
32 template struct X<int>;
33}
34
Douglas Gregor06f32b32010-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 Gregor205a3612010-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 Gregor93ded322011-03-04 22:45:55 +000053
54namespace PR7904 {
David Majnemer8e1a9132015-01-15 07:04:38 +000055 struct Foo {};
56 template <class T>
57 Foo::~Foo() { // expected-error{{destructor cannot be declared as a template}}
58 T t;
59 T &pT = t;
60 pT;
61 }
Douglas Gregor93ded322011-03-04 22:45:55 +000062 Foo f;
63}
Douglas Gregora88c55b2013-03-08 21:25:01 +000064
65namespace rdar13140795 {
66 template <class T> class shared_ptr {};
67
68 template <typename T> struct Marshal {
69 static int gc();
70 };
71
72
73 template <typename T> int Marshal<T>::gc() {
74 shared_ptr<T> *x;
75 x->template shared_ptr<T>::~shared_ptr();
76 return 0;
77 }
78
79 void test() {
80 Marshal<int>::gc();
81 }
82}
Eli Friedman85641392013-08-09 23:37:05 +000083
84namespace PR16852 {
85 template<typename T> struct S { int a; T x; };
86 template<typename T> decltype(S<T>().~S()) f(); // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
87 void g() { f(); } // expected-error {{no matching function for call to 'f'}}
88}