1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2 3 template<typename A> class s0 { 4 5 template<typename B> class s1 : public s0<A> { ~s1()6 ~s1() {} 7 s0<A> ms0; 8 }; 9 10 }; 11 12 struct Incomplete; 13 14 template<typename T> destroy_me(T me)15void destroy_me(T me) { 16 me.~T(); 17 } 18 19 template void destroy_me(Incomplete*); 20 21 namespace PR6152 { 22 template<typename T> struct X { void f(); }; 23 template<typename T> struct Y { }; 24 template<typename T> f()25 void X<T>::f() { 26 Y<T> *y; 27 y->template Y<T>::~Y(); 28 y->template Y<T>::~Y<T>(); 29 y->~Y(); 30 } 31 32 template struct X<int>; 33 } 34 35 namespace cvquals { 36 template<typename T> f(int * ptr)37 void f(int *ptr) { 38 ptr->~T(); 39 } 40 41 template void f<const volatile int>(int *); 42 } 43 44 namespace PR7239 { 45 template<class E> class A { }; 46 class B { f()47 void f() { 48 A<int>* x; 49 x->A<int>::~A<int>(); 50 } 51 }; 52 } 53 54 namespace PR7904 { 55 struct Foo {}; 56 template <class T> ~Foo()57 Foo::~Foo() { // expected-error{{destructor cannot be declared as a template}} 58 T t; 59 T &pT = t; 60 pT; 61 } 62 Foo f; 63 } 64 65 namespace rdar13140795 { 66 template <class T> class shared_ptr {}; 67 68 template <typename T> struct Marshal { 69 static int gc(); 70 }; 71 72 gc()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 test()79 void test() { 80 Marshal<int>::gc(); 81 } 82 } 83 84 namespace 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'}} g()87 void g() { f(); } // expected-error {{no matching function for call to 'f'}} 88 } 89