blob: b9c850b8b87b1e91f67b80c0e792f882ff03888a [file] [log] [blame]
Aaron Ballman674cf262015-05-26 19:44:52 +00001// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 %s
2// RUN: %clang_cc1 -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 %s
3// RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
4// RUN: %clang_cc1 -triple x86_64-windows-gnu -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G64 %s
Evgeniy Stepanov9d09d8a2015-07-15 18:57:57 +00005// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -fms-compatibility-version=18.00 -emit-llvm -std=c++1y -O1 -disable-llvm-optzns -o - %s -DMSABI -w | FileCheck --check-prefix=MO1 --check-prefix=M18 %s
6// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -fms-compatibility-version=19.00 -emit-llvm -std=c++1y -O1 -disable-llvm-optzns -o - %s -DMSABI -w | FileCheck --check-prefix=MO1 --check-prefix=M19 %s
Aaron Ballman674cf262015-05-26 19:44:52 +00007// RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O1 -o - %s -w | FileCheck --check-prefix=GO1 %s
Hans Wennborgb0f2f142014-05-15 22:07:49 +00008
Hans Wennborg910640b2014-06-04 21:09:46 +00009// CHECK-NOT doesn't play nice with CHECK-DAG, so use separate run lines.
Aaron Ballman674cf262015-05-26 19:44:52 +000010// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC2 %s
11// RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU2 %s
Hans Wennborg910640b2014-06-04 21:09:46 +000012
Nico Rieck755a36f2014-05-25 10:34:16 +000013// Helper structs to make templates more expressive.
14struct ImplicitInst_Imported {};
15struct ImplicitInst_NotImported {};
16struct ExplicitDecl_Imported {};
17struct ExplicitInst_Imported {};
18struct ExplicitSpec_Imported {};
19struct ExplicitSpec_Def_Imported {};
20struct ExplicitSpec_InlineDef_Imported {};
21struct ExplicitSpec_NotImported {};
Hans Wennborgb0f2f142014-05-15 22:07:49 +000022
Nico Rieck755a36f2014-05-25 10:34:16 +000023#define JOIN2(x, y) x##y
24#define JOIN(x, y) JOIN2(x, y)
25#define UNIQ(name) JOIN(name, __LINE__)
26#define USEVARTYPE(type, var) type UNIQ(use)() { return var; }
27#define USEVAR(var) USEVARTYPE(int, var)
28#define USE(func) void UNIQ(use)() { func(); }
Hans Wennborg853ae942014-05-30 16:59:42 +000029#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; }
30#define USECLASS(class) void UNIQ(USE)() { class x; }
Hans Wennborge8ad3832014-06-11 22:44:39 +000031#define USECOPYASSIGN(class) class& (class::*UNIQ(use)())(class&) { return &class::operator=; }
32#define USEMOVEASSIGN(class) class& (class::*UNIQ(use)())(class&&) { return &class::operator=; }
Hans Wennborgb0f2f142014-05-15 22:07:49 +000033
Nico Rieck755a36f2014-05-25 10:34:16 +000034//===----------------------------------------------------------------------===//
35// Globals
36//===----------------------------------------------------------------------===//
37
38// Import declaration.
39// MSC-DAG: @"\01?ExternGlobalDecl@@3HA" = external dllimport global i32
40// GNU-DAG: @ExternGlobalDecl = external dllimport global i32
41__declspec(dllimport) extern int ExternGlobalDecl;
42USEVAR(ExternGlobalDecl)
43
44// dllimport implies a declaration.
45// MSC-DAG: @"\01?GlobalDecl@@3HA" = external dllimport global i32
46// GNU-DAG: @GlobalDecl = external dllimport global i32
47__declspec(dllimport) int GlobalDecl;
48USEVAR(GlobalDecl)
49
50// Redeclarations
51// MSC-DAG: @"\01?GlobalRedecl1@@3HA" = external dllimport global i32
52// GNU-DAG: @GlobalRedecl1 = external dllimport global i32
53__declspec(dllimport) extern int GlobalRedecl1;
54__declspec(dllimport) extern int GlobalRedecl1;
55USEVAR(GlobalRedecl1)
56
57// MSC-DAG: @"\01?GlobalRedecl2a@@3HA" = external dllimport global i32
58// GNU-DAG: @GlobalRedecl2a = external dllimport global i32
59__declspec(dllimport) int GlobalRedecl2a;
60__declspec(dllimport) int GlobalRedecl2a;
61USEVAR(GlobalRedecl2a)
62
63// M32-DAG: @"\01?GlobalRedecl2b@@3PAHA" = external dllimport global i32*
64// M64-DAG: @"\01?GlobalRedecl2b@@3PEAHEA" = external dllimport global i32*
65// GNU-DAG: @GlobalRedecl2b = external dllimport global i32*
66int *__attribute__((dllimport)) GlobalRedecl2b;
67int *__attribute__((dllimport)) GlobalRedecl2b;
68USEVARTYPE(int*, GlobalRedecl2b)
69
70// MSC-DAG: @"\01?GlobalRedecl2c@@3HA" = external dllimport global i32
71// GNU-DAG: @GlobalRedecl2c = external dllimport global i32
72int GlobalRedecl2c __attribute__((dllimport));
73int GlobalRedecl2c __attribute__((dllimport));
74USEVAR(GlobalRedecl2c)
75
76// NB: MSC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC
77// and drop the dllimport with a warning.
78// MSC-DAG: @"\01?GlobalRedecl3@@3HA" = external global i32
79// GNU-DAG: @GlobalRedecl3 = external global i32
80__declspec(dllimport) extern int GlobalRedecl3;
81 extern int GlobalRedecl3; // dllimport ignored
82USEVAR(GlobalRedecl3)
83
84// MSC-DAG: @"\01?ExternalGlobal@ns@@3HA" = external dllimport global i32
85// GNU-DAG: @_ZN2ns14ExternalGlobalE = external dllimport global i32
86namespace ns { __declspec(dllimport) int ExternalGlobal; }
87USEVAR(ns::ExternalGlobal)
88
Hans Wennborg6eaa8322015-08-28 21:47:01 +000089int __declspec(dllimport) f();
Hans Wennborgef2272c2014-06-18 15:55:13 +000090// MO1-DAG: @"\01?x@?1??inlineStaticLocalsFunc@@YAHXZ@4HA" = available_externally dllimport global i32 0
91// MO1-DAG: @"\01??_B?1??inlineStaticLocalsFunc@@YAHXZ@51" = available_externally dllimport global i32 0
92inline int __declspec(dllimport) inlineStaticLocalsFunc() {
93 static int x = f();
94 return x++;
95};
96USE(inlineStaticLocalsFunc);
97
Hans Wennborg82dd8772014-06-25 22:19:48 +000098// The address of a dllimport global cannot be used in constant initialization.
David Majnemer040fa342014-10-05 06:44:53 +000099// M32-DAG: @"\01?arr@?1??initializationFunc@@YAPAHXZ@4QBQAHB" = internal global [1 x i32*] zeroinitializer
Hans Wennborg82dd8772014-06-25 22:19:48 +0000100// GNU-DAG: @_ZZ18initializationFuncvE3arr = internal global [1 x i32*] zeroinitializer
101int *initializationFunc() {
102 static int *const arr[] = {&ExternGlobalDecl};
103 return arr[0];
104}
105USE(initializationFunc);
Nico Rieck755a36f2014-05-25 10:34:16 +0000106
107
108//===----------------------------------------------------------------------===//
109// Variable templates
110//===----------------------------------------------------------------------===//
111
112// Import declaration.
113// MSC-DAG: @"\01??$ExternVarTmplDecl@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
114// GNU-DAG: @_Z17ExternVarTmplDeclI21ImplicitInst_ImportedE = external dllimport global i32
115template<typename T> __declspec(dllimport) extern int ExternVarTmplDecl;
116USEVAR(ExternVarTmplDecl<ImplicitInst_Imported>)
117
118// dllimport implies a declaration.
119// MSC-DAG: @"\01??$VarTmplDecl@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
120// GNU-DAG: @_Z11VarTmplDeclI21ImplicitInst_ImportedE = external dllimport global i32
121template<typename T> __declspec(dllimport) int VarTmplDecl;
122USEVAR(VarTmplDecl<ImplicitInst_Imported>)
123
124// Redeclarations
125// MSC-DAG: @"\01??$VarTmplRedecl1@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
126// GNU-DAG: @_Z14VarTmplRedecl1I21ImplicitInst_ImportedE = external dllimport global i32
127template<typename T> __declspec(dllimport) extern int VarTmplRedecl1;
128template<typename T> __declspec(dllimport) extern int VarTmplRedecl1;
129USEVAR(VarTmplRedecl1<ImplicitInst_Imported>)
130
131// MSC-DAG: @"\01??$VarTmplRedecl2@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
132// GNU-DAG: @_Z14VarTmplRedecl2I21ImplicitInst_ImportedE = external dllimport global i32
133template<typename T> __declspec(dllimport) int VarTmplRedecl2;
134template<typename T> __declspec(dllimport) int VarTmplRedecl2;
135USEVAR(VarTmplRedecl2<ImplicitInst_Imported>)
136
137// MSC-DAG: @"\01??$VarTmplRedecl3@UImplicitInst_Imported@@@@3HA" = external global i32
138// GNU-DAG: @_Z14VarTmplRedecl3I21ImplicitInst_ImportedE = external global i32
139template<typename T> __declspec(dllimport) extern int VarTmplRedecl3;
140template<typename T> extern int VarTmplRedecl3; // dllimport ignored
141USEVAR(VarTmplRedecl3<ImplicitInst_Imported>)
142
143
144// MSC-DAG: @"\01??$ExternalVarTmpl@UImplicitInst_Imported@@@ns@@3HA" = external dllimport global i32
145// GNU-DAG: @_ZN2ns15ExternalVarTmplI21ImplicitInst_ImportedEE = external dllimport global i32
146namespace ns { template<typename T> __declspec(dllimport) int ExternalVarTmpl; }
147USEVAR(ns::ExternalVarTmpl<ImplicitInst_Imported>)
148
149
150template<typename T> int VarTmpl;
151template<typename T> __declspec(dllimport) int ImportedVarTmpl;
152
153// Import implicit instantiation of an imported variable template.
154// MSC-DAG: @"\01??$ImportedVarTmpl@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
155// GNU-DAG: @_Z15ImportedVarTmplI21ImplicitInst_ImportedE = external dllimport global i32
156USEVAR(ImportedVarTmpl<ImplicitInst_Imported>)
157
158// Import explicit instantiation declaration of an imported variable template.
159// MSC-DAG: @"\01??$ImportedVarTmpl@UExplicitDecl_Imported@@@@3HA" = external dllimport global i32
160// GNU-DAG: @_Z15ImportedVarTmplI21ExplicitDecl_ImportedE = external dllimport global i32
161extern template int ImportedVarTmpl<ExplicitDecl_Imported>;
162USEVAR(ImportedVarTmpl<ExplicitDecl_Imported>)
163
164// An explicit instantiation definition of an imported variable template cannot
165// be imported because the template must be defined which is illegal.
166
167// Import specialization of an imported variable template.
168// MSC-DAG: @"\01??$ImportedVarTmpl@UExplicitSpec_Imported@@@@3HA" = external dllimport global i32
169// GNU-DAG: @_Z15ImportedVarTmplI21ExplicitSpec_ImportedE = external dllimport global i32
170template<> __declspec(dllimport) int ImportedVarTmpl<ExplicitSpec_Imported>;
171USEVAR(ImportedVarTmpl<ExplicitSpec_Imported>)
172
173// Not importing specialization of an imported variable template without
174// explicit dllimport.
175// MSC-DAG: @"\01??$ImportedVarTmpl@UExplicitSpec_NotImported@@@@3HA" = global i32 0, align 4
176// GNU-DAG: @_Z15ImportedVarTmplI24ExplicitSpec_NotImportedE = global i32 0, align 4
177template<> int ImportedVarTmpl<ExplicitSpec_NotImported>;
178USEVAR(ImportedVarTmpl<ExplicitSpec_NotImported>)
179
180// Import explicit instantiation declaration of a non-imported variable template.
181// MSC-DAG: @"\01??$VarTmpl@UExplicitDecl_Imported@@@@3HA" = external dllimport global i32
182// GNU-DAG: @_Z7VarTmplI21ExplicitDecl_ImportedE = external dllimport global i32
183extern template __declspec(dllimport) int VarTmpl<ExplicitDecl_Imported>;
184USEVAR(VarTmpl<ExplicitDecl_Imported>)
185
186// Import explicit instantiation definition of a non-imported variable template.
187// MSC-DAG: @"\01??$VarTmpl@UExplicitInst_Imported@@@@3HA" = external dllimport global i32
188// GNU-DAG: @_Z7VarTmplI21ExplicitInst_ImportedE = external dllimport global i32
189template __declspec(dllimport) int VarTmpl<ExplicitInst_Imported>;
190USEVAR(VarTmpl<ExplicitInst_Imported>)
191
192// Import specialization of a non-imported variable template.
193// MSC-DAG: @"\01??$VarTmpl@UExplicitSpec_Imported@@@@3HA" = external dllimport global i32
194// GNU-DAG: @_Z7VarTmplI21ExplicitSpec_ImportedE = external dllimport global i32
195template<> __declspec(dllimport) int VarTmpl<ExplicitSpec_Imported>;
196USEVAR(VarTmpl<ExplicitSpec_Imported>)
197
198
199
200//===----------------------------------------------------------------------===//
201// Functions
202//===----------------------------------------------------------------------===//
203
204// Import function declaration.
205// MSC-DAG: declare dllimport void @"\01?decl@@YAXXZ"()
206// GNU-DAG: declare dllimport void @_Z4declv()
207__declspec(dllimport) void decl();
208USE(decl)
209
210// extern "C"
211// MSC-DAG: declare dllimport void @externC()
212// GNU-DAG: declare dllimport void @externC()
213extern "C" __declspec(dllimport) void externC();
214USE(externC)
215
216// Import inline function.
217// MSC-DAG: declare dllimport void @"\01?inlineFunc@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000218// GNU-DAG: define linkonce_odr void @_Z10inlineFuncv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000219// MO1-DAG: define available_externally dllimport void @"\01?inlineFunc@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000220// GO1-DAG: define linkonce_odr void @_Z10inlineFuncv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000221__declspec(dllimport) inline void inlineFunc() {}
222USE(inlineFunc)
223
224// MSC-DAG: declare dllimport void @"\01?inlineDecl@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000225// GNU-DAG: define linkonce_odr void @_Z10inlineDeclv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000226// MO1-DAG: define available_externally dllimport void @"\01?inlineDecl@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000227// GO1-DAG: define linkonce_odr void @_Z10inlineDeclv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000228__declspec(dllimport) inline void inlineDecl();
229 void inlineDecl() {}
230USE(inlineDecl)
231
232// MSC-DAG: declare dllimport void @"\01?inlineDef@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000233// GNU-DAG: define linkonce_odr void @_Z9inlineDefv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000234// MO1-DAG: define available_externally dllimport void @"\01?inlineDef@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000235// GO1-DAG: define linkonce_odr void @_Z9inlineDefv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000236__declspec(dllimport) void inlineDef();
237 inline void inlineDef() {}
238USE(inlineDef)
239
240// inline attributes
241// MSC-DAG: declare dllimport void @"\01?noinline@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000242// GNU-DAG: define linkonce_odr void @_Z8noinlinev()
Nico Rieck755a36f2014-05-25 10:34:16 +0000243__declspec(dllimport) __attribute__((noinline)) inline void noinline() {}
244USE(noinline)
245
Hans Wennborg910640b2014-06-04 21:09:46 +0000246// MSC2-NOT: @"\01?alwaysInline@@YAXXZ"()
David Majnemer9f77e902015-05-05 20:34:29 +0000247// GNU2-NOT: @_Z12alwaysInlinev()
Hans Wennborg910640b2014-06-04 21:09:46 +0000248__declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {}
249USE(alwaysInline)
250
Nico Rieck755a36f2014-05-25 10:34:16 +0000251// Redeclarations
252// MSC-DAG: declare dllimport void @"\01?redecl1@@YAXXZ"()
253// GNU-DAG: declare dllimport void @_Z7redecl1v()
254__declspec(dllimport) void redecl1();
255__declspec(dllimport) void redecl1();
256USE(redecl1)
257
258// NB: MSC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC
259// and drop the dllimport with a warning.
260// MSC-DAG: declare void @"\01?redecl2@@YAXXZ"()
261// GNU-DAG: declare void @_Z7redecl2v()
262__declspec(dllimport) void redecl2();
263 void redecl2();
264USE(redecl2)
265
266// MSC-DAG: define void @"\01?redecl3@@YAXXZ"()
267// GNU-DAG: define void @_Z7redecl3v()
268__declspec(dllimport) void redecl3();
269 void redecl3() {} // dllimport ignored
270USE(redecl3)
271
272
273// Friend functions
274// MSC-DAG: declare dllimport void @"\01?friend1@@YAXXZ"()
275// GNU-DAG: declare dllimport void @_Z7friend1v()
276// MSC-DAG: declare void @"\01?friend2@@YAXXZ"()
277// GNU-DAG: declare void @_Z7friend2v()
278// MSC-DAG: define void @"\01?friend3@@YAXXZ"()
279// GNU-DAG: define void @_Z7friend3v()
Hans Wennborg7c4851e2014-08-04 20:54:39 +0000280// MSC-DAG: declare void @"\01?friend4@@YAXXZ"()
281// GNU-DAG: declare void @_Z7friend4v()
282// MSC-DAG: declare dllimport void @"\01?friend5@@YAXXZ"()
283// GNU-DAG: declare dllimport void @_Z7friend5v()
284
Nico Rieck755a36f2014-05-25 10:34:16 +0000285struct FuncFriend {
286 friend __declspec(dllimport) void friend1();
287 friend __declspec(dllimport) void friend2();
288 friend __declspec(dllimport) void friend3();
Hans Wennborgb0f2f142014-05-15 22:07:49 +0000289};
Nico Rieck755a36f2014-05-25 10:34:16 +0000290__declspec(dllimport) void friend1();
291 void friend2(); // dllimport ignored
292 void friend3() {} // dllimport ignored
Hans Wennborg7c4851e2014-08-04 20:54:39 +0000293
294__declspec(dllimport) void friend4();
295__declspec(dllimport) void friend5();
296struct FuncFriendRedecl {
297 friend void friend4(); // dllimport ignored
298 friend void ::friend5();
299};
Nico Rieck755a36f2014-05-25 10:34:16 +0000300USE(friend1)
301USE(friend2)
302USE(friend3)
Hans Wennborg7c4851e2014-08-04 20:54:39 +0000303USE(friend4)
304USE(friend5)
Hans Wennborgb0f2f142014-05-15 22:07:49 +0000305
Nico Rieck755a36f2014-05-25 10:34:16 +0000306// Implicit declarations can be redeclared with dllimport.
307// MSC-DAG: declare dllimport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"(
308// GNU-DAG: declare dllimport noalias i8* @_Znw{{[yj]}}(
309__declspec(dllimport) void* operator new(__SIZE_TYPE__ n);
310void UNIQ(use)() { ::operator new(42); }
311
312// MSC-DAG: declare dllimport void @"\01?externalFunc@ns@@YAXXZ"()
313// GNU-DAG: declare dllimport void @_ZN2ns12externalFuncEv()
314namespace ns { __declspec(dllimport) void externalFunc(); }
315USE(ns::externalFunc)
316
Hans Wennborg6eaa8322015-08-28 21:47:01 +0000317// A dllimport function referencing non-imported vars or functions must not be available_externally.
318__declspec(dllimport) int ImportedVar;
319int NonImportedVar;
320__declspec(dllimport) int ImportedFunc();
321int NonImportedFunc();
322__declspec(dllimport) inline int ReferencingImportedVar() { return ImportedVar; }
323// MO1-DAG: define available_externally dllimport i32 @"\01?ReferencingImportedVar@@YAHXZ"
324__declspec(dllimport) inline int ReferencingNonImportedVar() { return NonImportedVar; }
325// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedVar@@YAHXZ"()
326__declspec(dllimport) inline int ReferencingImportedFunc() { return ImportedFunc(); }
327// MO1-DAG: define available_externally dllimport i32 @"\01?ReferencingImportedFunc@@YAHXZ"
328__declspec(dllimport) inline int ReferencingNonImportedFunc() { return NonImportedFunc(); }
329// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedFunc@@YAHXZ"()
330USE(ReferencingImportedVar)
331USE(ReferencingNonImportedVar)
332USE(ReferencingImportedFunc)
333USE(ReferencingNonImportedFunc)
334// References to operator new and delete count too, despite not being DeclRefExprs.
335__declspec(dllimport) inline int *ReferencingNonImportedNew() { return new int[2]; }
336// MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedNew@@YAPAHXZ"
337__declspec(dllimport) inline int *ReferencingNonImportedDelete() { delete (int*)nullptr; }
338// MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedDelete@@YAPAHXZ"
339USE(ReferencingNonImportedNew)
340USE(ReferencingNonImportedDelete)
341__declspec(dllimport) void* operator new[](__SIZE_TYPE__);
342__declspec(dllimport) void operator delete(void*);
343__declspec(dllimport) inline int *ReferencingImportedNew() { return new int[2]; }
344// MO1-DAG: define available_externally dllimport i32* @"\01?ReferencingImportedNew@@YAPAHXZ"
345__declspec(dllimport) inline int *ReferencingImportedDelete() { delete (int*)nullptr; }
346// MO1-DAG: define available_externally dllimport i32* @"\01?ReferencingImportedDelete@@YAPAHXZ"
347USE(ReferencingImportedNew)
348USE(ReferencingImportedDelete)
349
350// A dllimport function with a TLS variable must not be available_externally.
351__declspec(dllimport) inline void FunctionWithTLSVar() { static __thread int x = 42; }
352// MO1-DAG: declare dllimport void @"\01?FunctionWithTLSVar@@YAXXZ"
353__declspec(dllimport) inline void FunctionWithNormalVar() { static int x = 42; }
354// MO1-DAG: define available_externally dllimport void @"\01?FunctionWithNormalVar@@YAXXZ"
355USE(FunctionWithTLSVar)
356USE(FunctionWithNormalVar)
Nico Rieck755a36f2014-05-25 10:34:16 +0000357
358
359//===----------------------------------------------------------------------===//
360// Function templates
361//===----------------------------------------------------------------------===//
362
363// Import function template declaration.
364// MSC-DAG: declare dllimport void @"\01??$funcTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
365// GNU-DAG: declare dllimport void @_Z12funcTmplDeclI21ImplicitInst_ImportedEvv()
366template<typename T> __declspec(dllimport) void funcTmplDecl();
367USE(funcTmplDecl<ImplicitInst_Imported>)
368
369// Function template definitions cannot be imported.
370
371// Import inline function template.
372// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000373// GNU-DAG: define linkonce_odr void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000374// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000375// GO1-DAG: define linkonce_odr void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000376template<typename T> __declspec(dllimport) inline void inlineFuncTmpl1() {}
377USE(inlineFuncTmpl1<ImplicitInst_Imported>)
378
379// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000380// GNU-DAG: define linkonce_odr void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000381// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000382// GO1-DAG: define linkonce_odr void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000383template<typename T> inline void __attribute__((dllimport)) inlineFuncTmpl2() {}
384USE(inlineFuncTmpl2<ImplicitInst_Imported>)
385
386// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000387// GNU-DAG: define linkonce_odr void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000388// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000389// GO1-DAG: define linkonce_odr void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000390template<typename T> __declspec(dllimport) inline void inlineFuncTmplDecl();
391template<typename T> void inlineFuncTmplDecl() {}
392USE(inlineFuncTmplDecl<ImplicitInst_Imported>)
393
394// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000395// GNU-DAG: define linkonce_odr void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000396// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000397// GO1-DAG: define linkonce_odr void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000398template<typename T> __declspec(dllimport) void inlineFuncTmplDef();
399template<typename T> inline void inlineFuncTmplDef() {}
400USE(inlineFuncTmplDef<ImplicitInst_Imported>)
401
402
403// Redeclarations
404// MSC-DAG: declare dllimport void @"\01??$funcTmplRedecl1@UImplicitInst_Imported@@@@YAXXZ"()
405// GNU-DAG: declare dllimport void @_Z15funcTmplRedecl1I21ImplicitInst_ImportedEvv()
406template<typename T> __declspec(dllimport) void funcTmplRedecl1();
407template<typename T> __declspec(dllimport) void funcTmplRedecl1();
408USE(funcTmplRedecl1<ImplicitInst_Imported>)
409
410// MSC-DAG: declare void @"\01??$funcTmplRedecl2@UImplicitInst_NotImported@@@@YAXXZ"()
411// GNU-DAG: declare void @_Z15funcTmplRedecl2I24ImplicitInst_NotImportedEvv()
412template<typename T> __declspec(dllimport) void funcTmplRedecl2();
413template<typename T> void funcTmplRedecl2(); // dllimport ignored
414USE(funcTmplRedecl2<ImplicitInst_NotImported>)
415
416// MSC-DAG: define linkonce_odr void @"\01??$funcTmplRedecl3@UImplicitInst_NotImported@@@@YAXXZ"()
417// GNU-DAG: define linkonce_odr void @_Z15funcTmplRedecl3I24ImplicitInst_NotImportedEvv()
418template<typename T> __declspec(dllimport) void funcTmplRedecl3();
419template<typename T> void funcTmplRedecl3() {} // dllimport ignored
420USE(funcTmplRedecl3<ImplicitInst_NotImported>)
421
422
423// Function template friends
424// MSC-DAG: declare dllimport void @"\01??$funcTmplFriend1@UImplicitInst_Imported@@@@YAXXZ"()
425// GNU-DAG: declare dllimport void @_Z15funcTmplFriend1I21ImplicitInst_ImportedEvv()
426// MSC-DAG: declare void @"\01??$funcTmplFriend2@UImplicitInst_NotImported@@@@YAXXZ"()
427// GNU-DAG: declare void @_Z15funcTmplFriend2I24ImplicitInst_NotImportedEvv()
428// MSC-DAG: define linkonce_odr void @"\01??$funcTmplFriend3@UImplicitInst_NotImported@@@@YAXXZ"()
429// GNU-DAG: define linkonce_odr void @_Z15funcTmplFriend3I24ImplicitInst_NotImportedEvv()
430// MSC-DAG: declare dllimport void @"\01??$funcTmplFriend4@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000431// GNU-DAG: define linkonce_odr void @_Z15funcTmplFriend4I21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000432struct FuncTmplFriend {
433 template<typename T> friend __declspec(dllimport) void funcTmplFriend1();
434 template<typename T> friend __declspec(dllimport) void funcTmplFriend2();
435 template<typename T> friend __declspec(dllimport) void funcTmplFriend3();
436 template<typename T> friend __declspec(dllimport) inline void funcTmplFriend4();
437};
438template<typename T> __declspec(dllimport) void funcTmplFriend1();
439template<typename T> void funcTmplFriend2(); // dllimport ignored
440template<typename T> void funcTmplFriend3() {} // dllimport ignored
441template<typename T> inline void funcTmplFriend4() {}
442USE(funcTmplFriend1<ImplicitInst_Imported>)
443USE(funcTmplFriend2<ImplicitInst_NotImported>)
444USE(funcTmplFriend3<ImplicitInst_NotImported>)
445USE(funcTmplFriend4<ImplicitInst_Imported>)
446
447// MSC-DAG: declare dllimport void @"\01??$externalFuncTmpl@UImplicitInst_Imported@@@ns@@YAXXZ"()
448// GNU-DAG: declare dllimport void @_ZN2ns16externalFuncTmplI21ImplicitInst_ImportedEEvv()
449namespace ns { template<typename T> __declspec(dllimport) void externalFuncTmpl(); }
450USE(ns::externalFuncTmpl<ImplicitInst_Imported>)
451
452
453template<typename T> void funcTmpl() {}
454template<typename T> inline void inlineFuncTmpl() {}
455template<typename T> __declspec(dllimport) void importedFuncTmplDecl();
456template<typename T> __declspec(dllimport) inline void importedFuncTmpl() {}
457
458// Import implicit instantiation of an imported function template.
459// MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
460// GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI21ImplicitInst_ImportedEvv()
461USE(importedFuncTmplDecl<ImplicitInst_Imported>)
462
463// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000464// GNU-DAG: define linkonce_odr void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000465// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000466// GO1-DAG: define linkonce_odr void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000467USE(importedFuncTmpl<ImplicitInst_Imported>)
468
469// Import explicit instantiation declaration of an imported function template.
470// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000471// GNU-DAG: declare void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000472// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000473// GO1-DAG: define available_externally void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000474extern template void importedFuncTmpl<ExplicitDecl_Imported>();
475USE(importedFuncTmpl<ExplicitDecl_Imported>)
476
477// Import explicit instantiation definition of an imported function template.
478// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000479// GNU-DAG: define weak_odr void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000480// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000481// GO1-DAG: define weak_odr void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000482template void importedFuncTmpl<ExplicitInst_Imported>();
483USE(importedFuncTmpl<ExplicitInst_Imported>)
484
485
486// Import specialization of an imported function template.
487// MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Imported@@@@YAXXZ"()
488// GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI21ExplicitSpec_ImportedEvv()
489template<> __declspec(dllimport) void importedFuncTmplDecl<ExplicitSpec_Imported>();
490USE(importedFuncTmplDecl<ExplicitSpec_Imported>)
491
492// MSC-DAG-FIXME: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
493// MO1-DAG-FIXME: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
494#ifdef MSABI
495//template<> __declspec(dllimport) void importedFuncTmplDecl<ExplicitSpec_Def_Imported>() {}
496//USE(importedFuncTmplDecl<ExplicitSpec_Def_Imported>)
497#endif
498
499// MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000500// GNU-DAG: define linkonce_odr void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000501// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000502// GO1-DAG: define linkonce_odr void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000503template<> __declspec(dllimport) inline void importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>() {}
504USE(importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>)
505
506
507// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Imported@@@@YAXXZ"()
508// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitSpec_ImportedEvv()
509template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Imported>();
510USE(importedFuncTmpl<ExplicitSpec_Imported>)
511
512// MSC-DAG-FIXME: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
513// MO1-DAG-FIXME: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
514#ifdef MSABI
515//template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Def_Imported>() {}
516//USE(importedFuncTmpl<ExplicitSpec_Def_Imported>)
517#endif
518
519// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000520// GNU-DAG: define linkonce_odr void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000521// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000522// GO1-DAG: define linkonce_odr void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000523template<> __declspec(dllimport) inline void importedFuncTmpl<ExplicitSpec_InlineDef_Imported>() {}
524USE(importedFuncTmpl<ExplicitSpec_InlineDef_Imported>)
525
526
527// Not importing specialization of an imported function template without
528// explicit dllimport.
529// MSC-DAG: define void @"\01??$importedFuncTmpl@UExplicitSpec_NotImported@@@@YAXXZ"()
530// GNU-DAG: define void @_Z16importedFuncTmplI24ExplicitSpec_NotImportedEvv()
531template<> void importedFuncTmpl<ExplicitSpec_NotImported>() {}
532USE(importedFuncTmpl<ExplicitSpec_NotImported>)
533
534
535// Import explicit instantiation declaration of a non-imported function template.
536// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
537// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
538// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitDecl_ImportedEvv()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000539// GNU-DAG: declare void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000540// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000541// GO1-DAG: define available_externally void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000542extern template __declspec(dllimport) void funcTmpl<ExplicitDecl_Imported>();
543extern template __declspec(dllimport) void inlineFuncTmpl<ExplicitDecl_Imported>();
544USE(funcTmpl<ExplicitDecl_Imported>)
545USE(inlineFuncTmpl<ExplicitDecl_Imported>)
546
547
548// Import explicit instantiation definition of a non-imported function template.
549// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
550// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
551// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000552// GNU-DAG: define weak_odr void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000553// MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
554// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
555// GO1-DAG: define available_externally dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000556// GO1-DAG: define weak_odr void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000557template __declspec(dllimport) void funcTmpl<ExplicitInst_Imported>();
558template __declspec(dllimport) void inlineFuncTmpl<ExplicitInst_Imported>();
559USE(funcTmpl<ExplicitInst_Imported>)
560USE(inlineFuncTmpl<ExplicitInst_Imported>)
561
562
563// Import specialization of a non-imported function template.
564// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_Imported@@@@YAXXZ"()
565// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitSpec_ImportedEvv()
566template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Imported>();
567USE(funcTmpl<ExplicitSpec_Imported>)
568
569// MSC-DAG-FIXME: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
570// MO1-DAG-FIXME: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
571#ifdef MSABI
572//template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Def_Imported>() {}
573//USE(funcTmpl<ExplicitSpec_Def_Imported>)
574#endif
575
576// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000577// GNU-DAG: define linkonce_odr void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000578// MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000579// GO1-DAG: define linkonce_odr void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
Nico Rieck755a36f2014-05-25 10:34:16 +0000580template<> __declspec(dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {}
581USE(funcTmpl<ExplicitSpec_InlineDef_Imported>)
Hans Wennborg853ae942014-05-30 16:59:42 +0000582
583
584
585//===----------------------------------------------------------------------===//
586// Classes
587//===----------------------------------------------------------------------===//
588
589struct __declspec(dllimport) T {
590 void a() {}
591 // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?a@T@@QAEXXZ"
592
593 static int b;
594 // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32
Hans Wennborge8ad3832014-06-11 22:44:39 +0000595
596 T& operator=(T&) = default;
Hal Finkela2347ba2014-07-18 15:52:10 +0000597 // MO1-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@AAU0@@Z"
Hans Wennborge8ad3832014-06-11 22:44:39 +0000598
599 T& operator=(T&&) = default;
600 // Note: Don't mark inline move operators dllimport because current MSVC versions don't export them.
David Majnemer30f058a2015-05-11 03:00:22 +0000601 // M18-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
602 // M19-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
Hans Wennborg853ae942014-05-30 16:59:42 +0000603};
604USEMEMFUNC(T, a)
605USEVAR(T::b)
Hans Wennborge8ad3832014-06-11 22:44:39 +0000606USECOPYASSIGN(T)
607USEMOVEASSIGN(T)
Hans Wennborg853ae942014-05-30 16:59:42 +0000608
609template <typename T> struct __declspec(dllimport) U { void foo() {} };
610// MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?foo@?$U@H@@QAEXXZ"
611struct __declspec(dllimport) V : public U<int> { };
612USEMEMFUNC(V, foo)
613
614struct __declspec(dllimport) W { virtual void foo() {} };
615USECLASS(W)
616// vftable:
617// MO1-DAG: @"\01??_7W@@6B@" = available_externally dllimport unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
Hans Wennborgda24e9c2014-06-02 23:13:03 +0000618// GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)]
619
620struct __declspec(dllimport) KeyFuncClass {
621 constexpr KeyFuncClass() {}
622 virtual void foo();
623};
Richard Smith7747ce22015-08-19 20:49:38 +0000624extern constexpr KeyFuncClass keyFuncClassVar = {};
Hans Wennborgda24e9c2014-06-02 23:13:03 +0000625// G32-DAG: @_ZTV12KeyFuncClass = external dllimport unnamed_addr constant [3 x i8*]
Hans Wennborg853ae942014-05-30 16:59:42 +0000626
627struct __declspec(dllimport) X : public virtual W {};
628USECLASS(X)
629// vbtable:
630// MO1-DAG: @"\01??_8X@@7B@" = available_externally dllimport unnamed_addr constant [2 x i32] [i32 0, i32 4]
631
632struct __declspec(dllimport) Y {
633 int x;
634};
635
636struct __declspec(dllimport) Z { virtual ~Z() {} };
637USECLASS(Z)
638// User-defined dtor:
639// MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1Z@@UAE@XZ"
640
641namespace DontUseDtorAlias {
642 struct __declspec(dllimport) A { ~A(); };
643 struct __declspec(dllimport) B : A { ~B(); };
644 inline A::~A() { }
645 inline B::~B() { }
646 // Emit a real definition of B's constructor; don't alias it to A's.
647 // MO1-DAG: available_externally dllimport x86_thiscallcc void @"\01??1B@DontUseDtorAlias@@QAE@XZ"
648 USECLASS(B)
649}
650
651namespace Vtordisp {
652 // Don't dllimport the vtordisp.
Hans Wennborgc94391d2014-06-06 20:04:01 +0000653 // MO1-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPPPPPM@A@AEXXZ"
Hans Wennborg853ae942014-05-30 16:59:42 +0000654
655 class Base {
656 virtual void f() {}
657 };
658 template <typename T>
659 class __declspec(dllimport) C : virtual public Base {
660 public:
661 C() {}
662 virtual void f() {}
663 };
664 template class C<char>;
665}
Hans Wennborgda24e9c2014-06-02 23:13:03 +0000666
Hans Wennborge9af3162014-06-04 00:18:41 +0000667namespace ClassTemplateStaticDef {
Hans Wennborgcd959222014-06-09 18:30:28 +0000668 // Regular template static field:
Hans Wennborge9af3162014-06-04 00:18:41 +0000669 template <typename T> struct __declspec(dllimport) S {
670 static int x;
671 };
672 template <typename T> int S<T>::x;
Hans Wennborgcd959222014-06-09 18:30:28 +0000673 // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = available_externally dllimport global i32 0
Hans Wennborge9af3162014-06-04 00:18:41 +0000674 int f() { return S<int>::x; }
Hans Wennborgcd959222014-06-09 18:30:28 +0000675
676 // Partial class template specialization static field:
677 template <typename A> struct T;
678 template <typename A> struct __declspec(dllimport) T<A*> {
679 static int x;
680 };
681 template <typename A> int T<A*>::x;
Hans Wennborg5e645282014-06-24 23:57:13 +0000682 // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE = available_externally dllimport global i32 0
Hans Wennborgcd959222014-06-09 18:30:28 +0000683 int g() { return T<void*>::x; }
Hans Wennborge9af3162014-06-04 00:18:41 +0000684}
685
Hans Wennborg910640b2014-06-04 21:09:46 +0000686namespace PR19933 {
687// Don't dynamically initialize dllimport vars.
688// MSC2-NOT: @llvm.global_ctors
689// GNU2-NOT: @llvm.global_ctors
Hans Wennborgda24e9c2014-06-02 23:13:03 +0000690
Hans Wennborg910640b2014-06-04 21:09:46 +0000691 struct NonPOD { NonPOD(); };
692 template <typename T> struct A { static NonPOD x; };
693 template <typename T> NonPOD A<T>::x;
694 template struct __declspec(dllimport) A<int>;
695 // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = available_externally dllimport global %"struct.PR19933::NonPOD" zeroinitializer
Hans Wennborgda24e9c2014-06-02 23:13:03 +0000696
Hans Wennborg910640b2014-06-04 21:09:46 +0000697 int f();
698 template <typename T> struct B { static int x; };
699 template <typename T> int B<T>::x = f();
700 template struct __declspec(dllimport) B<int>;
701 // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = available_externally dllimport global i32 0
702
703 constexpr int g() { return 42; }
704 template <typename T> struct C { static int x; };
705 template <typename T> int C<T>::x = g();
706 template struct __declspec(dllimport) C<int>;
707 // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42
Hans Wennborg91ebe6e2014-06-10 00:55:51 +0000708
709 template <int I> struct D { static int x, y; };
710 template <int I> int D<I>::x = I + 1;
711 template <int I> int D<I>::y = I + f();
712 template struct __declspec(dllimport) D<42>;
713 // MSC-DAG: @"\01?x@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 43
714 // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
Hans Wennborg910640b2014-06-04 21:09:46 +0000715}
Hans Wennborg5e645282014-06-24 23:57:13 +0000716
Hans Wennborgec53c292014-10-23 22:40:46 +0000717namespace PR21355 {
718 struct __declspec(dllimport) S {
719 virtual ~S();
720 };
721 S::~S() {}
722
723 // S::~S is a key function, so we would ordinarily emit a strong definition for
724 // the vtable. However, S is imported, so the vtable should be too.
725
726 // GNU-DAG: @_ZTVN7PR213551SE = available_externally dllimport unnamed_addr constant [4 x i8*]
727}
728
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000729namespace PR21366 {
730 struct __declspec(dllimport) S {
731 void outOfLineMethod();
732 void inlineMethod() {}
733 inline void anotherInlineMethod();
734 void outOfClassInlineMethod();
735 };
736 void S::anotherInlineMethod() {}
737 inline void S::outOfClassInlineMethod() {}
738}
739
Hans Wennborg5e645282014-06-24 23:57:13 +0000740// MS ignores DLL attributes on partial specializations.
741template <typename T> struct PartiallySpecializedClassTemplate {};
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000742template <typename T> struct __declspec(dllimport) PartiallySpecializedClassTemplate<T*> { void f(); };
Hans Wennborg5e645282014-06-24 23:57:13 +0000743USEMEMFUNC(PartiallySpecializedClassTemplate<void*>, f);
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000744// M32-DAG: declare x86_thiscallcc void @"\01?f@?$PartiallySpecializedClassTemplate@PAX@@QAEXXZ"
745// G32-DAG: declare dllimport x86_thiscallcc void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv
Hans Wennborg5e645282014-06-24 23:57:13 +0000746
Hans Wennborg205c39b2014-08-23 22:34:43 +0000747// Attributes on explicit specializations are honored.
Hans Wennborg5e645282014-06-24 23:57:13 +0000748template <typename T> struct ExplicitlySpecializedClassTemplate {};
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000749template <> struct __declspec(dllimport) ExplicitlySpecializedClassTemplate<void*> { void f(); };
Hans Wennborg5e645282014-06-24 23:57:13 +0000750USEMEMFUNC(ExplicitlySpecializedClassTemplate<void*>, f);
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000751// M32-DAG: declare dllimport x86_thiscallcc void @"\01?f@?$ExplicitlySpecializedClassTemplate@PAX@@QAEXXZ"
752// G32-DAG: declare dllimport x86_thiscallcc void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000753
Hans Wennborg205c39b2014-08-23 22:34:43 +0000754// MS inherits DLL attributes to partial specializations.
755template <typename T> struct __declspec(dllimport) PartiallySpecializedImportedClassTemplate {};
756template <typename T> struct PartiallySpecializedImportedClassTemplate<T*> { void f() {} };
757USEMEMFUNC(PartiallySpecializedImportedClassTemplate<void*>, f);
758// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$PartiallySpecializedImportedClassTemplate@PAX@@QAEXXZ"
759// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN41PartiallySpecializedImportedClassTemplateIPvE1fEv
760
Hans Wennborgc2b7f7a2014-08-24 00:12:36 +0000761// Attributes on the instantiation take precedence over attributes on the template.
762template <typename T> struct __declspec(dllexport) ExplicitlyInstantiatedWithDifferentAttr { void f() {} };
763template struct __declspec(dllimport) ExplicitlyInstantiatedWithDifferentAttr<int>;
764USEMEMFUNC(ExplicitlyInstantiatedWithDifferentAttr<int>, f);
765// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$ExplicitlyInstantiatedWithDifferentAttr@H@@QAEXXZ"
766
Hans Wennborgbb4f9622015-05-28 17:44:56 +0000767template <typename T> struct ExplicitInstantiationDeclImportedDefTemplate { void f() {} ExplicitInstantiationDeclImportedDefTemplate() {}};
Hans Wennborg17f9b442015-05-27 00:06:45 +0000768extern template struct ExplicitInstantiationDeclImportedDefTemplate<int>;
769template struct __declspec(dllimport) ExplicitInstantiationDeclImportedDefTemplate<int>;
Hans Wennborgbb4f9622015-05-28 17:44:56 +0000770USECLASS(ExplicitInstantiationDeclImportedDefTemplate<int>);
Hans Wennborg17f9b442015-05-27 00:06:45 +0000771USEMEMFUNC(ExplicitInstantiationDeclImportedDefTemplate<int>, f);
772// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$ExplicitInstantiationDeclImportedDefTemplate@H@@QAEXXZ"
Hans Wennborgbb4f9622015-05-28 17:44:56 +0000773// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc %struct.ExplicitInstantiationDeclImportedDefTemplate* @"\01??0?$ExplicitInstantiationDeclImportedDefTemplate@H@@QAE@XZ"
Hans Wennborgc0875502015-06-09 00:39:05 +0000774// G32-DAG: define weak_odr x86_thiscallcc void @_ZN44ExplicitInstantiationDeclImportedDefTemplateIiE1fEv
Hans Wennborg17f9b442015-05-27 00:06:45 +0000775
Hans Wennborgbb4f9622015-05-28 17:44:56 +0000776template <typename T> struct __declspec(dllimport) ExplicitInstantiationDeclExportedDefImportedTemplate { void f() {} ExplicitInstantiationDeclExportedDefImportedTemplate() {} };
Hans Wennborg17f9b442015-05-27 00:06:45 +0000777extern template struct __declspec(dllimport) ExplicitInstantiationDeclExportedDefImportedTemplate <int>;
778template struct __declspec(dllexport) ExplicitInstantiationDeclExportedDefImportedTemplate<int>;
Hans Wennborgbb4f9622015-05-28 17:44:56 +0000779USECLASS(ExplicitInstantiationDeclExportedDefImportedTemplate<int>);
Hans Wennborg17f9b442015-05-27 00:06:45 +0000780USEMEMFUNC(ExplicitInstantiationDeclExportedDefImportedTemplate<int>, f);
781// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$ExplicitInstantiationDeclExportedDefImportedTemplate@H@@QAEXXZ"
Hans Wennborgbb4f9622015-05-28 17:44:56 +0000782// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc %struct.ExplicitInstantiationDeclExportedDefImportedTemplate* @"\01??0?$ExplicitInstantiationDeclExportedDefImportedTemplate@H@@QAE@XZ"
Hans Wennborg17f9b442015-05-27 00:06:45 +0000783
Hans Wennborgfce87ca2015-06-09 00:39:09 +0000784template <typename T> struct PR23770BaseTemplate { void f() {} };
785template <typename T> struct PR23770DerivedTemplate : PR23770BaseTemplate<int> {};
786extern template struct PR23770DerivedTemplate<int>;
787template struct __declspec(dllimport) PR23770DerivedTemplate<int>;
788USEMEMFUNC(PR23770BaseTemplate<int>, f);
789// M32-DAG: declare dllimport x86_thiscallcc void @"\01?f@?$PR23770BaseTemplate@H@@QAEXXZ"
Hans Wennborg205c39b2014-08-23 22:34:43 +0000790
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000791//===----------------------------------------------------------------------===//
792// Classes with template base classes
793//===----------------------------------------------------------------------===//
794
795template <typename T> struct ClassTemplate { void func() {} };
Hans Wennborg97cbed42015-02-19 22:39:24 +0000796template <typename T> struct __declspec(dllexport) ExportedClassTemplate { void func(); };
797template <typename T> void ExportedClassTemplate<T>::func() {}
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000798template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func(); };
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000799
800template <typename T> struct ExplicitlySpecializedTemplate { void func() {} };
801template <> struct ExplicitlySpecializedTemplate<int> { void func() {} };
802template <typename T> struct ExplicitlyExportSpecializedTemplate { void func() {} };
Hans Wennborg97cbed42015-02-19 22:39:24 +0000803template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate<int> { void func(); };
804void ExplicitlyExportSpecializedTemplate<int>::func() {}
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000805template <typename T> struct ExplicitlyImportSpecializedTemplate { void func() {} };
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000806template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func(); };
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000807
808template <typename T> struct ExplicitlyInstantiatedTemplate { void func() {} };
809template struct ExplicitlyInstantiatedTemplate<int>;
Hans Wennborg97cbed42015-02-19 22:39:24 +0000810template <typename T> struct ExplicitlyExportInstantiatedTemplate { void func(); };
811template <typename T> void ExplicitlyExportInstantiatedTemplate<T>::func() {}
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000812template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate<int>;
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000813template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func(); };
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000814template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate<int>;
815
816
817// MS: ClassTemplate<int> gets imported.
818struct __declspec(dllimport) DerivedFromTemplate : public ClassTemplate<int> {};
819USEMEMFUNC(ClassTemplate<int>, func)
820// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ClassTemplate@H@@QAEXXZ"
821// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ClassTemplateIiE4funcEv
822
823// ImportedTemplate is explicitly imported.
824struct __declspec(dllimport) DerivedFromImportedTemplate : public ImportedClassTemplate<int> {};
825USEMEMFUNC(ImportedClassTemplate<int>, func)
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000826// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ImportedClassTemplate@H@@QAEXXZ"
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000827// G32-DAG: declare dllimport x86_thiscallcc void @_ZN21ImportedClassTemplateIiE4funcEv
828
829// ExportedTemplate is explicitly exported.
830struct __declspec(dllimport) DerivedFromExportedTemplate : public ExportedClassTemplate<int> {};
831USEMEMFUNC(ExportedClassTemplate<int>, func)
832// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExportedClassTemplate@H@@QAEXXZ"
833// G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN21ExportedClassTemplateIiE4funcEv
834
Hans Wennborgbb1983c2015-06-09 00:39:03 +0000835// Base class already implicitly instantiated without attribute.
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000836struct DerivedFromTemplateD : public ClassTemplate<double> {};
837struct __declspec(dllimport) DerivedFromTemplateD2 : public ClassTemplate<double> {};
838USEMEMFUNC(ClassTemplate<double>, func)
Hans Wennborgbb1983c2015-06-09 00:39:03 +0000839// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ClassTemplate@N@@QAEXXZ"
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000840// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ClassTemplateIdE4funcEv
841
842// MS: Base class already instantiated with dfferent attribute.
843struct __declspec(dllexport) DerivedFromTemplateB : public ClassTemplate<bool> {};
844struct __declspec(dllimport) DerivedFromTemplateB2 : public ClassTemplate<bool> {};
845USEMEMFUNC(ClassTemplate<bool>, func)
846// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ClassTemplate@_N@@QAEXXZ"
847// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ClassTemplateIbE4funcEv
848
849// Base class already specialized without dll attribute.
850struct __declspec(dllimport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {};
851USEMEMFUNC(ExplicitlySpecializedTemplate<int>, func)
852// M32-DAG: define linkonce_odr x86_thiscallcc void @"\01?func@?$ExplicitlySpecializedTemplate@H@@QAEXXZ"
853// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv
854
855// Base class alredy specialized with export attribute.
856struct __declspec(dllimport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate<int> {};
857USEMEMFUNC(ExplicitlyExportSpecializedTemplate<int>, func)
Hans Wennborg97cbed42015-02-19 22:39:24 +0000858// M32-DAG: define dllexport x86_thiscallcc void @"\01?func@?$ExplicitlyExportSpecializedTemplate@H@@QAEXXZ"
859// G32-DAG: define dllexport x86_thiscallcc void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000860
861// Base class already specialized with import attribute.
862struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {};
863USEMEMFUNC(ExplicitlyImportSpecializedTemplate<int>, func)
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000864// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ"
865// G32-DAG: declare dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000866
867// Base class already instantiated without dll attribute.
868struct __declspec(dllimport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {};
869USEMEMFUNC(ExplicitlyInstantiatedTemplate<int>, func)
870// M32-DAG: define weak_odr x86_thiscallcc void @"\01?func@?$ExplicitlyInstantiatedTemplate@H@@QAEXXZ"
871// G32-DAG: define weak_odr x86_thiscallcc void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv
872
873// Base class already instantiated with export attribute.
874struct __declspec(dllimport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate<int> {};
875USEMEMFUNC(ExplicitlyExportInstantiatedTemplate<int>, func)
876// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitlyExportInstantiatedTemplate@H@@QAEXXZ"
877// G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv
878
879// Base class already instantiated with import attribute.
880struct __declspec(dllimport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate<int> {};
881USEMEMFUNC(ExplicitlyImportInstantiatedTemplate<int>, func)
Hans Wennborg606bd6d2014-11-03 14:24:45 +0000882// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ"
883// G32-DAG: declare dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000884
885// MS: A dll attribute propagates through multiple levels of instantiation.
886template <typename T> struct TopClass { void func() {} };
887template <typename T> struct MiddleClass : public TopClass<T> { };
Alp Toker958027b2014-07-14 19:42:55 +0000888struct __declspec(dllimport) BottomClass : public MiddleClass<int> { };
Hans Wennborg9bea9cc2014-06-25 18:25:57 +0000889USEMEMFUNC(TopClass<int>, func)
890// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$TopClass@H@@QAEXXZ"
891// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN8TopClassIiE4funcEv
Hans Wennborgbb1983c2015-06-09 00:39:03 +0000892
893template <typename T> struct ExplicitInstantiationDeclTemplateBase { void func() {} };
894extern template struct ExplicitInstantiationDeclTemplateBase<int>;
895struct __declspec(dllimport) DerivedFromExplicitInstantiationDeclTemplateBase : public ExplicitInstantiationDeclTemplateBase<int> {};
896template struct ExplicitInstantiationDeclTemplateBase<int>;
897USEMEMFUNC(ExplicitInstantiationDeclTemplateBase<int>, func)
898// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
899// G32-DAG: define weak_odr x86_thiscallcc void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
900
901template <typename T> struct ExplicitInstantiationDeclTemplateBase2 { void func() {} };
902extern template struct ExplicitInstantiationDeclTemplateBase2<int>;
903struct __declspec(dllimport) DerivedFromExplicitInstantiationDeclTemplateBase2 : public ExplicitInstantiationDeclTemplateBase2<int> {};
904template struct __declspec(dllexport) ExplicitInstantiationDeclTemplateBase2<int>;
905USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2<int>, func)
906// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
907// G32-DAG: define weak_odr x86_thiscallcc void @_ZN38ExplicitInstantiationDeclTemplateBase2IiE4funcEv