[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / SemaTemplate / extern-templates.cpp
blobefc4690bbb2c679c01e626157e0a7360a92cf3d1
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
4 template<typename T>
5 class X0 {
6 public:
7 void f(T t);
9 struct Inner {
10 void g(T t);
14 template<typename T>
15 void X0<T>::f(T t) {
16 t = 17; // expected-error{{incompatible}}
19 extern template class X0<int>;
21 extern template class X0<int*>;
23 template<typename T>
24 void X0<T>::Inner::g(T t) {
25 #ifdef MS
26 t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}} expected-error{{incompatible integer to pointer conversion assigning to 'int *'}}
27 #else
28 t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}}
29 #endif
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
41 extern template class X0<long*>;
43 void test_longptr(X0<long*> xl, X0<long*>::Inner xli) {
44 xl.f(0);
45 xli.g(0);
48 template class X0<long*>; // expected-note 2{{instantiation}}
50 template<typename T>
51 class X1 {
52 public:
53 void f(T t) { t += 2; }
55 void g(T t);
58 template<typename T>
59 void X1<T>::g(T t) {
60 t += 2;
63 extern template class X1<void*>;
65 void g_X1(X1<void*> x1, void *ptr) {
66 x1.g(ptr);
69 extern template void X1<const void*>::g(const void*);
71 void g_X1_2(X1<const void *> x1, const void *ptr) {
72 x1.g(ptr);
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];