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