[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaTemplate / instantiate-non-dependent-types.cpp
blobcfc1a7a6c309f95c4238d8833d0ea6ee76aacf8f
1 // RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify %std_cxx17- %s
3 template<typename T>
4 struct X1 {
5 static void member() { T* x = 1; } // precxx17-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
6 };
8 template<void(*)()> struct instantiate { };
10 template<typename T>
11 struct X2 {
12 typedef instantiate<&X1<int>::member> i; // precxx17-note{{in instantiation of}}
15 X2<int> x;
17 template <class T, class A> class C {
18 public:
19 int i;
20 void f(T &t) {
21 T *q = new T();
22 t.T::~T();
23 q->~T();
24 // expected-error@+2 {{'int' is not a class, namespace, or enumeration}}
25 // expected-error@+1 {{no member named '~Colors' in 'Colors'}}
26 q->A::~A();
27 // expected-error@+2 {{no member named '~int' in 'Q'}}
28 // expected-error@+1 {{no member named '~Colors' in 'Q'}}
29 q->~A();
31 delete q;
35 class Q {
36 public:
37 Q() {}
38 ~Q() {}
41 enum Colors {red, green, blue};
43 C<Q, int> dummy;
44 C<Q, Colors> dummyColors;
45 int main() {
46 Q qinst;
47 // expected-note@+1 {{in instantiation of member function 'C<Q, int>::f' requested here}}
48 dummy.f(qinst);
49 // expected-note@+1 {{in instantiation of member function 'C<Q, Colors>::f' requested here}}
50 dummyColors.f(qinst);