1 // RUN: %clang_cc1 -triple i686-pc-win32 -fsyntax-only -verify %s -DMS
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu-pc-win32 -fsyntax-only -verify %s
3 
4 template<typename T>
5 class X0 {
6 public:
7   void f(T t);
8 
9   struct Inner {
10     void g(T t);
11   };
12 };
13 
14 template<typename T>
f(T t)15 void X0<T>::f(T t) {
16   t = 17; // expected-error{{incompatible}}
17 }
18 
19 extern template class X0<int>;
20 
21 extern template class X0<int*>;
22 
23 template<typename T>
g(T t)24 void X0<T>::Inner::g(T t) {
25 #ifdef MS
26   t = 17; // expected-error{{assigning to 'long *' from incompatible}} expected-error{{assigning to 'int *' from incompatible}}
27 #else
28   t = 17; // expected-error{{assigning to 'long *' from incompatible}}
29 #endif
30 }
31 
test_intptr(X0<int * > xi,X0<int * >::Inner xii)32 void test_intptr(X0<int*> xi, X0<int*>::Inner xii) {
33   xi.f(0);
34 #ifdef MS
35   xii.g(0); // expected-note {{instantiation}}
36 #else
37   xii.g(0);
38 #endif
39 }
40 
41 extern template class X0<long*>;
42 
test_longptr(X0<long * > xl,X0<long * >::Inner xli)43 void test_longptr(X0<long*> xl, X0<long*>::Inner xli) {
44   xl.f(0);
45   xli.g(0);
46 }
47 
48 template class X0<long*>; // expected-note 2{{instantiation}}
49 
50 template<typename T>
51 class X1 {
52 public:
f(T t)53   void f(T t) { t += 2; }
54 
55   void g(T t);
56 };
57 
58 template<typename T>
g(T t)59 void X1<T>::g(T t) {
60   t += 2;
61 }
62 
63 extern template class X1<void*>;
64 
g_X1(X1<void * > x1,void * ptr)65 void g_X1(X1<void*> x1, void *ptr) {
66   x1.g(ptr);
67 }
68 
69 extern template void X1<const void*>::g(const void*);
70 
g_X1_2(X1<const void * > x1,const void * ptr)71 void g_X1_2(X1<const void *> x1, const void *ptr) {
72   x1.g(ptr);
73 }
74 
75 namespace static_const_member {
76   template <typename T> struct A { static const int n; };
77   template <typename T> const int A<T>::n = 3;
78   extern template struct A<int>;
79   int arr[A<int>::n];
80 }
81