[clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::inferFrameworkModule()
[llvm-project.git] / clang / test / SemaTemplate / destructor-template.cpp
blob89018829476231904a2ba405b2648d86b0014dc0
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 template<typename A> class s0 {
5 template<typename B> class s1 : public s0<A> {
6 ~s1() {}
7 s0<A> ms0;
8 };
12 struct Incomplete;
14 template<typename T>
15 void destroy_me(T me) {
16 me.~T();
19 template void destroy_me(Incomplete*);
21 namespace 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();
28 y->template Y<T>::~Y<T>();
29 y->~Y();
32 template struct X<int>;
35 namespace cvquals {
36 template<typename T>
37 void f(int *ptr) {
38 ptr->~T();
41 template void f<const volatile int>(int *);
44 namespace PR7239 {
45 template<class E> class A { };
46 class B {
47 void f() {
48 A<int>* x;
49 x->A<int>::~A<int>();
54 namespace PR7904 {
55 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;
62 Foo f;
65 namespace rdar13140795 {
66 template <class T> class shared_ptr {};
68 template <typename T> struct Marshal {
69 static int 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;
79 void test() {
80 Marshal<int>::gc();
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'}}
87 void g() { f(); } // expected-error {{no matching function for call to 'f'}}
90 class PR33189
92 template <class T>
93 ~PR33189() { } // expected-error{{destructor cannot be declared as a template}}
96 namespace PR38671 {
97 struct S {
98 template <class>
99 ~S(); // expected-error{{destructor cannot be declared as a template}}
101 struct T : S {
102 ~T() = default;
104 } // namespace PR38671