blob: a0d153e408da1d6fcb4330f3df3eef4c06940ffb [file] [log] [blame]
Hans Wennborg853ae942014-05-30 16:59:42 +00001// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC --check-prefix=M32 %s
2// RUN: %clang_cc1 -triple x86_64-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC --check-prefix=M64 %s
3// RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G32 %s
4// RUN: %clang_cc1 -triple x86_64-windows-gnu -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G64 %s
5// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O1 -o - %s -DMSABI | FileCheck --check-prefix=MO1 %s
6// RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -emit-llvm -std=c++1y -O1 -o - %s | FileCheck --check-prefix=GO1 %s
Hans Wennborgb0f2f142014-05-15 22:07:49 +00007
Nico Rieck755a36f2014-05-25 10:34:16 +00008// Helper structs to make templates more expressive.
9struct ImplicitInst_Imported {};
10struct ImplicitInst_NotImported {};
11struct ExplicitDecl_Imported {};
12struct ExplicitInst_Imported {};
13struct ExplicitSpec_Imported {};
14struct ExplicitSpec_Def_Imported {};
15struct ExplicitSpec_InlineDef_Imported {};
16struct ExplicitSpec_NotImported {};
Hans Wennborgb0f2f142014-05-15 22:07:49 +000017
Nico Rieck755a36f2014-05-25 10:34:16 +000018#define JOIN2(x, y) x##y
19#define JOIN(x, y) JOIN2(x, y)
20#define UNIQ(name) JOIN(name, __LINE__)
21#define USEVARTYPE(type, var) type UNIQ(use)() { return var; }
22#define USEVAR(var) USEVARTYPE(int, var)
23#define USE(func) void UNIQ(use)() { func(); }
Hans Wennborg853ae942014-05-30 16:59:42 +000024#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; }
25#define USECLASS(class) void UNIQ(USE)() { class x; }
Hans Wennborgb0f2f142014-05-15 22:07:49 +000026
Nico Rieck755a36f2014-05-25 10:34:16 +000027//===----------------------------------------------------------------------===//
28// Globals
29//===----------------------------------------------------------------------===//
30
31// Import declaration.
32// MSC-DAG: @"\01?ExternGlobalDecl@@3HA" = external dllimport global i32
33// GNU-DAG: @ExternGlobalDecl = external dllimport global i32
34__declspec(dllimport) extern int ExternGlobalDecl;
35USEVAR(ExternGlobalDecl)
36
37// dllimport implies a declaration.
38// MSC-DAG: @"\01?GlobalDecl@@3HA" = external dllimport global i32
39// GNU-DAG: @GlobalDecl = external dllimport global i32
40__declspec(dllimport) int GlobalDecl;
41USEVAR(GlobalDecl)
42
43// Redeclarations
44// MSC-DAG: @"\01?GlobalRedecl1@@3HA" = external dllimport global i32
45// GNU-DAG: @GlobalRedecl1 = external dllimport global i32
46__declspec(dllimport) extern int GlobalRedecl1;
47__declspec(dllimport) extern int GlobalRedecl1;
48USEVAR(GlobalRedecl1)
49
50// MSC-DAG: @"\01?GlobalRedecl2a@@3HA" = external dllimport global i32
51// GNU-DAG: @GlobalRedecl2a = external dllimport global i32
52__declspec(dllimport) int GlobalRedecl2a;
53__declspec(dllimport) int GlobalRedecl2a;
54USEVAR(GlobalRedecl2a)
55
56// M32-DAG: @"\01?GlobalRedecl2b@@3PAHA" = external dllimport global i32*
57// M64-DAG: @"\01?GlobalRedecl2b@@3PEAHEA" = external dllimport global i32*
58// GNU-DAG: @GlobalRedecl2b = external dllimport global i32*
59int *__attribute__((dllimport)) GlobalRedecl2b;
60int *__attribute__((dllimport)) GlobalRedecl2b;
61USEVARTYPE(int*, GlobalRedecl2b)
62
63// MSC-DAG: @"\01?GlobalRedecl2c@@3HA" = external dllimport global i32
64// GNU-DAG: @GlobalRedecl2c = external dllimport global i32
65int GlobalRedecl2c __attribute__((dllimport));
66int GlobalRedecl2c __attribute__((dllimport));
67USEVAR(GlobalRedecl2c)
68
69// NB: MSC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC
70// and drop the dllimport with a warning.
71// MSC-DAG: @"\01?GlobalRedecl3@@3HA" = external global i32
72// GNU-DAG: @GlobalRedecl3 = external global i32
73__declspec(dllimport) extern int GlobalRedecl3;
74 extern int GlobalRedecl3; // dllimport ignored
75USEVAR(GlobalRedecl3)
76
77// MSC-DAG: @"\01?ExternalGlobal@ns@@3HA" = external dllimport global i32
78// GNU-DAG: @_ZN2ns14ExternalGlobalE = external dllimport global i32
79namespace ns { __declspec(dllimport) int ExternalGlobal; }
80USEVAR(ns::ExternalGlobal)
81
82
83
84//===----------------------------------------------------------------------===//
85// Variable templates
86//===----------------------------------------------------------------------===//
87
88// Import declaration.
89// MSC-DAG: @"\01??$ExternVarTmplDecl@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
90// GNU-DAG: @_Z17ExternVarTmplDeclI21ImplicitInst_ImportedE = external dllimport global i32
91template<typename T> __declspec(dllimport) extern int ExternVarTmplDecl;
92USEVAR(ExternVarTmplDecl<ImplicitInst_Imported>)
93
94// dllimport implies a declaration.
95// MSC-DAG: @"\01??$VarTmplDecl@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
96// GNU-DAG: @_Z11VarTmplDeclI21ImplicitInst_ImportedE = external dllimport global i32
97template<typename T> __declspec(dllimport) int VarTmplDecl;
98USEVAR(VarTmplDecl<ImplicitInst_Imported>)
99
100// Redeclarations
101// MSC-DAG: @"\01??$VarTmplRedecl1@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
102// GNU-DAG: @_Z14VarTmplRedecl1I21ImplicitInst_ImportedE = external dllimport global i32
103template<typename T> __declspec(dllimport) extern int VarTmplRedecl1;
104template<typename T> __declspec(dllimport) extern int VarTmplRedecl1;
105USEVAR(VarTmplRedecl1<ImplicitInst_Imported>)
106
107// MSC-DAG: @"\01??$VarTmplRedecl2@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
108// GNU-DAG: @_Z14VarTmplRedecl2I21ImplicitInst_ImportedE = external dllimport global i32
109template<typename T> __declspec(dllimport) int VarTmplRedecl2;
110template<typename T> __declspec(dllimport) int VarTmplRedecl2;
111USEVAR(VarTmplRedecl2<ImplicitInst_Imported>)
112
113// MSC-DAG: @"\01??$VarTmplRedecl3@UImplicitInst_Imported@@@@3HA" = external global i32
114// GNU-DAG: @_Z14VarTmplRedecl3I21ImplicitInst_ImportedE = external global i32
115template<typename T> __declspec(dllimport) extern int VarTmplRedecl3;
116template<typename T> extern int VarTmplRedecl3; // dllimport ignored
117USEVAR(VarTmplRedecl3<ImplicitInst_Imported>)
118
119
120// MSC-DAG: @"\01??$ExternalVarTmpl@UImplicitInst_Imported@@@ns@@3HA" = external dllimport global i32
121// GNU-DAG: @_ZN2ns15ExternalVarTmplI21ImplicitInst_ImportedEE = external dllimport global i32
122namespace ns { template<typename T> __declspec(dllimport) int ExternalVarTmpl; }
123USEVAR(ns::ExternalVarTmpl<ImplicitInst_Imported>)
124
125
126template<typename T> int VarTmpl;
127template<typename T> __declspec(dllimport) int ImportedVarTmpl;
128
129// Import implicit instantiation of an imported variable template.
130// MSC-DAG: @"\01??$ImportedVarTmpl@UImplicitInst_Imported@@@@3HA" = external dllimport global i32
131// GNU-DAG: @_Z15ImportedVarTmplI21ImplicitInst_ImportedE = external dllimport global i32
132USEVAR(ImportedVarTmpl<ImplicitInst_Imported>)
133
134// Import explicit instantiation declaration of an imported variable template.
135// MSC-DAG: @"\01??$ImportedVarTmpl@UExplicitDecl_Imported@@@@3HA" = external dllimport global i32
136// GNU-DAG: @_Z15ImportedVarTmplI21ExplicitDecl_ImportedE = external dllimport global i32
137extern template int ImportedVarTmpl<ExplicitDecl_Imported>;
138USEVAR(ImportedVarTmpl<ExplicitDecl_Imported>)
139
140// An explicit instantiation definition of an imported variable template cannot
141// be imported because the template must be defined which is illegal.
142
143// Import specialization of an imported variable template.
144// MSC-DAG: @"\01??$ImportedVarTmpl@UExplicitSpec_Imported@@@@3HA" = external dllimport global i32
145// GNU-DAG: @_Z15ImportedVarTmplI21ExplicitSpec_ImportedE = external dllimport global i32
146template<> __declspec(dllimport) int ImportedVarTmpl<ExplicitSpec_Imported>;
147USEVAR(ImportedVarTmpl<ExplicitSpec_Imported>)
148
149// Not importing specialization of an imported variable template without
150// explicit dllimport.
151// MSC-DAG: @"\01??$ImportedVarTmpl@UExplicitSpec_NotImported@@@@3HA" = global i32 0, align 4
152// GNU-DAG: @_Z15ImportedVarTmplI24ExplicitSpec_NotImportedE = global i32 0, align 4
153template<> int ImportedVarTmpl<ExplicitSpec_NotImported>;
154USEVAR(ImportedVarTmpl<ExplicitSpec_NotImported>)
155
156// Import explicit instantiation declaration of a non-imported variable template.
157// MSC-DAG: @"\01??$VarTmpl@UExplicitDecl_Imported@@@@3HA" = external dllimport global i32
158// GNU-DAG: @_Z7VarTmplI21ExplicitDecl_ImportedE = external dllimport global i32
159extern template __declspec(dllimport) int VarTmpl<ExplicitDecl_Imported>;
160USEVAR(VarTmpl<ExplicitDecl_Imported>)
161
162// Import explicit instantiation definition of a non-imported variable template.
163// MSC-DAG: @"\01??$VarTmpl@UExplicitInst_Imported@@@@3HA" = external dllimport global i32
164// GNU-DAG: @_Z7VarTmplI21ExplicitInst_ImportedE = external dllimport global i32
165template __declspec(dllimport) int VarTmpl<ExplicitInst_Imported>;
166USEVAR(VarTmpl<ExplicitInst_Imported>)
167
168// Import specialization of a non-imported variable template.
169// MSC-DAG: @"\01??$VarTmpl@UExplicitSpec_Imported@@@@3HA" = external dllimport global i32
170// GNU-DAG: @_Z7VarTmplI21ExplicitSpec_ImportedE = external dllimport global i32
171template<> __declspec(dllimport) int VarTmpl<ExplicitSpec_Imported>;
172USEVAR(VarTmpl<ExplicitSpec_Imported>)
173
174
175
176//===----------------------------------------------------------------------===//
177// Functions
178//===----------------------------------------------------------------------===//
179
180// Import function declaration.
181// MSC-DAG: declare dllimport void @"\01?decl@@YAXXZ"()
182// GNU-DAG: declare dllimport void @_Z4declv()
183__declspec(dllimport) void decl();
184USE(decl)
185
186// extern "C"
187// MSC-DAG: declare dllimport void @externC()
188// GNU-DAG: declare dllimport void @externC()
189extern "C" __declspec(dllimport) void externC();
190USE(externC)
191
192// Import inline function.
193// MSC-DAG: declare dllimport void @"\01?inlineFunc@@YAXXZ"()
194// GNU-DAG: declare dllimport void @_Z10inlineFuncv()
195// MO1-DAG: define available_externally dllimport void @"\01?inlineFunc@@YAXXZ"()
196// GO1-DAG: define available_externally dllimport void @_Z10inlineFuncv()
197__declspec(dllimport) inline void inlineFunc() {}
198USE(inlineFunc)
199
200// MSC-DAG: declare dllimport void @"\01?inlineDecl@@YAXXZ"()
201// GNU-DAG: declare dllimport void @_Z10inlineDeclv()
202// MO1-DAG: define available_externally dllimport void @"\01?inlineDecl@@YAXXZ"()
203// GO1-DAG: define available_externally dllimport void @_Z10inlineDeclv()
204__declspec(dllimport) inline void inlineDecl();
205 void inlineDecl() {}
206USE(inlineDecl)
207
208// MSC-DAG: declare dllimport void @"\01?inlineDef@@YAXXZ"()
209// GNU-DAG: declare dllimport void @_Z9inlineDefv()
210// MO1-DAG: define available_externally dllimport void @"\01?inlineDef@@YAXXZ"()
211// GO1-DAG: define available_externally dllimport void @_Z9inlineDefv()
212__declspec(dllimport) void inlineDef();
213 inline void inlineDef() {}
214USE(inlineDef)
215
216// inline attributes
217// MSC-DAG: declare dllimport void @"\01?noinline@@YAXXZ"()
218// GNU-DAG: declare dllimport void @_Z8noinlinev()
219__declspec(dllimport) __attribute__((noinline)) inline void noinline() {}
220USE(noinline)
221
222// MSC-NOT: @"\01?alwaysInline@@YAXXZ"()
223// GNU-NOT: @_Z12alwaysInlinev()
224__declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {}
225USE(alwaysInline)
226
227// Redeclarations
228// MSC-DAG: declare dllimport void @"\01?redecl1@@YAXXZ"()
229// GNU-DAG: declare dllimport void @_Z7redecl1v()
230__declspec(dllimport) void redecl1();
231__declspec(dllimport) void redecl1();
232USE(redecl1)
233
234// NB: MSC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC
235// and drop the dllimport with a warning.
236// MSC-DAG: declare void @"\01?redecl2@@YAXXZ"()
237// GNU-DAG: declare void @_Z7redecl2v()
238__declspec(dllimport) void redecl2();
239 void redecl2();
240USE(redecl2)
241
242// MSC-DAG: define void @"\01?redecl3@@YAXXZ"()
243// GNU-DAG: define void @_Z7redecl3v()
244__declspec(dllimport) void redecl3();
245 void redecl3() {} // dllimport ignored
246USE(redecl3)
247
248
249// Friend functions
250// MSC-DAG: declare dllimport void @"\01?friend1@@YAXXZ"()
251// GNU-DAG: declare dllimport void @_Z7friend1v()
252// MSC-DAG: declare void @"\01?friend2@@YAXXZ"()
253// GNU-DAG: declare void @_Z7friend2v()
254// MSC-DAG: define void @"\01?friend3@@YAXXZ"()
255// GNU-DAG: define void @_Z7friend3v()
256struct FuncFriend {
257 friend __declspec(dllimport) void friend1();
258 friend __declspec(dllimport) void friend2();
259 friend __declspec(dllimport) void friend3();
Hans Wennborgb0f2f142014-05-15 22:07:49 +0000260};
Nico Rieck755a36f2014-05-25 10:34:16 +0000261__declspec(dllimport) void friend1();
262 void friend2(); // dllimport ignored
263 void friend3() {} // dllimport ignored
264USE(friend1)
265USE(friend2)
266USE(friend3)
Hans Wennborgb0f2f142014-05-15 22:07:49 +0000267
Nico Rieck755a36f2014-05-25 10:34:16 +0000268// Implicit declarations can be redeclared with dllimport.
269// MSC-DAG: declare dllimport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"(
270// GNU-DAG: declare dllimport noalias i8* @_Znw{{[yj]}}(
271__declspec(dllimport) void* operator new(__SIZE_TYPE__ n);
272void UNIQ(use)() { ::operator new(42); }
273
274// MSC-DAG: declare dllimport void @"\01?externalFunc@ns@@YAXXZ"()
275// GNU-DAG: declare dllimport void @_ZN2ns12externalFuncEv()
276namespace ns { __declspec(dllimport) void externalFunc(); }
277USE(ns::externalFunc)
278
279
280
281//===----------------------------------------------------------------------===//
282// Function templates
283//===----------------------------------------------------------------------===//
284
285// Import function template declaration.
286// MSC-DAG: declare dllimport void @"\01??$funcTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
287// GNU-DAG: declare dllimport void @_Z12funcTmplDeclI21ImplicitInst_ImportedEvv()
288template<typename T> __declspec(dllimport) void funcTmplDecl();
289USE(funcTmplDecl<ImplicitInst_Imported>)
290
291// Function template definitions cannot be imported.
292
293// Import inline function template.
294// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"()
295// GNU-DAG: declare dllimport void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
296// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"()
297// GO1-DAG: define available_externally dllimport void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
298template<typename T> __declspec(dllimport) inline void inlineFuncTmpl1() {}
299USE(inlineFuncTmpl1<ImplicitInst_Imported>)
300
301// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"()
302// GNU-DAG: declare dllimport void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
303// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"()
304// GO1-DAG: define available_externally dllimport void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
305template<typename T> inline void __attribute__((dllimport)) inlineFuncTmpl2() {}
306USE(inlineFuncTmpl2<ImplicitInst_Imported>)
307
308// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
309// GNU-DAG: declare dllimport void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
310// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
311// GO1-DAG: define available_externally dllimport void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
312template<typename T> __declspec(dllimport) inline void inlineFuncTmplDecl();
313template<typename T> void inlineFuncTmplDecl() {}
314USE(inlineFuncTmplDecl<ImplicitInst_Imported>)
315
316// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"()
317// GNU-DAG: declare dllimport void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
318// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"()
319// GO1-DAG: define available_externally dllimport void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
320template<typename T> __declspec(dllimport) void inlineFuncTmplDef();
321template<typename T> inline void inlineFuncTmplDef() {}
322USE(inlineFuncTmplDef<ImplicitInst_Imported>)
323
324
325// Redeclarations
326// MSC-DAG: declare dllimport void @"\01??$funcTmplRedecl1@UImplicitInst_Imported@@@@YAXXZ"()
327// GNU-DAG: declare dllimport void @_Z15funcTmplRedecl1I21ImplicitInst_ImportedEvv()
328template<typename T> __declspec(dllimport) void funcTmplRedecl1();
329template<typename T> __declspec(dllimport) void funcTmplRedecl1();
330USE(funcTmplRedecl1<ImplicitInst_Imported>)
331
332// MSC-DAG: declare void @"\01??$funcTmplRedecl2@UImplicitInst_NotImported@@@@YAXXZ"()
333// GNU-DAG: declare void @_Z15funcTmplRedecl2I24ImplicitInst_NotImportedEvv()
334template<typename T> __declspec(dllimport) void funcTmplRedecl2();
335template<typename T> void funcTmplRedecl2(); // dllimport ignored
336USE(funcTmplRedecl2<ImplicitInst_NotImported>)
337
338// MSC-DAG: define linkonce_odr void @"\01??$funcTmplRedecl3@UImplicitInst_NotImported@@@@YAXXZ"()
339// GNU-DAG: define linkonce_odr void @_Z15funcTmplRedecl3I24ImplicitInst_NotImportedEvv()
340template<typename T> __declspec(dllimport) void funcTmplRedecl3();
341template<typename T> void funcTmplRedecl3() {} // dllimport ignored
342USE(funcTmplRedecl3<ImplicitInst_NotImported>)
343
344
345// Function template friends
346// MSC-DAG: declare dllimport void @"\01??$funcTmplFriend1@UImplicitInst_Imported@@@@YAXXZ"()
347// GNU-DAG: declare dllimport void @_Z15funcTmplFriend1I21ImplicitInst_ImportedEvv()
348// MSC-DAG: declare void @"\01??$funcTmplFriend2@UImplicitInst_NotImported@@@@YAXXZ"()
349// GNU-DAG: declare void @_Z15funcTmplFriend2I24ImplicitInst_NotImportedEvv()
350// MSC-DAG: define linkonce_odr void @"\01??$funcTmplFriend3@UImplicitInst_NotImported@@@@YAXXZ"()
351// GNU-DAG: define linkonce_odr void @_Z15funcTmplFriend3I24ImplicitInst_NotImportedEvv()
352// MSC-DAG: declare dllimport void @"\01??$funcTmplFriend4@UImplicitInst_Imported@@@@YAXXZ"()
353// GNU-DAG: declare dllimport void @_Z15funcTmplFriend4I21ImplicitInst_ImportedEvv()
354struct FuncTmplFriend {
355 template<typename T> friend __declspec(dllimport) void funcTmplFriend1();
356 template<typename T> friend __declspec(dllimport) void funcTmplFriend2();
357 template<typename T> friend __declspec(dllimport) void funcTmplFriend3();
358 template<typename T> friend __declspec(dllimport) inline void funcTmplFriend4();
359};
360template<typename T> __declspec(dllimport) void funcTmplFriend1();
361template<typename T> void funcTmplFriend2(); // dllimport ignored
362template<typename T> void funcTmplFriend3() {} // dllimport ignored
363template<typename T> inline void funcTmplFriend4() {}
364USE(funcTmplFriend1<ImplicitInst_Imported>)
365USE(funcTmplFriend2<ImplicitInst_NotImported>)
366USE(funcTmplFriend3<ImplicitInst_NotImported>)
367USE(funcTmplFriend4<ImplicitInst_Imported>)
368
369// MSC-DAG: declare dllimport void @"\01??$externalFuncTmpl@UImplicitInst_Imported@@@ns@@YAXXZ"()
370// GNU-DAG: declare dllimport void @_ZN2ns16externalFuncTmplI21ImplicitInst_ImportedEEvv()
371namespace ns { template<typename T> __declspec(dllimport) void externalFuncTmpl(); }
372USE(ns::externalFuncTmpl<ImplicitInst_Imported>)
373
374
375template<typename T> void funcTmpl() {}
376template<typename T> inline void inlineFuncTmpl() {}
377template<typename T> __declspec(dllimport) void importedFuncTmplDecl();
378template<typename T> __declspec(dllimport) inline void importedFuncTmpl() {}
379
380// Import implicit instantiation of an imported function template.
381// MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
382// GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI21ImplicitInst_ImportedEvv()
383USE(importedFuncTmplDecl<ImplicitInst_Imported>)
384
385// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"()
386// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
387// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"()
388// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
389USE(importedFuncTmpl<ImplicitInst_Imported>)
390
391// Import explicit instantiation declaration of an imported function template.
392// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
393// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
394// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
395// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
396extern template void importedFuncTmpl<ExplicitDecl_Imported>();
397USE(importedFuncTmpl<ExplicitDecl_Imported>)
398
399// Import explicit instantiation definition of an imported function template.
400// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
401// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
402// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
403// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
404template void importedFuncTmpl<ExplicitInst_Imported>();
405USE(importedFuncTmpl<ExplicitInst_Imported>)
406
407
408// Import specialization of an imported function template.
409// MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Imported@@@@YAXXZ"()
410// GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI21ExplicitSpec_ImportedEvv()
411template<> __declspec(dllimport) void importedFuncTmplDecl<ExplicitSpec_Imported>();
412USE(importedFuncTmplDecl<ExplicitSpec_Imported>)
413
414// MSC-DAG-FIXME: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
415// MO1-DAG-FIXME: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
416#ifdef MSABI
417//template<> __declspec(dllimport) void importedFuncTmplDecl<ExplicitSpec_Def_Imported>() {}
418//USE(importedFuncTmplDecl<ExplicitSpec_Def_Imported>)
419#endif
420
421// MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
422// GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
423// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
424// GO1-DAG: define available_externally dllimport void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
425template<> __declspec(dllimport) inline void importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>() {}
426USE(importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>)
427
428
429// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Imported@@@@YAXXZ"()
430// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitSpec_ImportedEvv()
431template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Imported>();
432USE(importedFuncTmpl<ExplicitSpec_Imported>)
433
434// MSC-DAG-FIXME: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
435// MO1-DAG-FIXME: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
436#ifdef MSABI
437//template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Def_Imported>() {}
438//USE(importedFuncTmpl<ExplicitSpec_Def_Imported>)
439#endif
440
441// MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
442// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
443// MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
444// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
445template<> __declspec(dllimport) inline void importedFuncTmpl<ExplicitSpec_InlineDef_Imported>() {}
446USE(importedFuncTmpl<ExplicitSpec_InlineDef_Imported>)
447
448
449// Not importing specialization of an imported function template without
450// explicit dllimport.
451// MSC-DAG: define void @"\01??$importedFuncTmpl@UExplicitSpec_NotImported@@@@YAXXZ"()
452// GNU-DAG: define void @_Z16importedFuncTmplI24ExplicitSpec_NotImportedEvv()
453template<> void importedFuncTmpl<ExplicitSpec_NotImported>() {}
454USE(importedFuncTmpl<ExplicitSpec_NotImported>)
455
456
457// Import explicit instantiation declaration of a non-imported function template.
458// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
459// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
460// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitDecl_ImportedEvv()
461// GNU-DAG: declare dllimport void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
462// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
463// GO1-DAG: define available_externally dllimport void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
464extern template __declspec(dllimport) void funcTmpl<ExplicitDecl_Imported>();
465extern template __declspec(dllimport) void inlineFuncTmpl<ExplicitDecl_Imported>();
466USE(funcTmpl<ExplicitDecl_Imported>)
467USE(inlineFuncTmpl<ExplicitDecl_Imported>)
468
469
470// Import explicit instantiation definition of a non-imported function template.
471// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
472// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
473// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
474// GNU-DAG: declare dllimport void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
475// MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
476// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
477// GO1-DAG: define available_externally dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
478// GO1-DAG: define available_externally dllimport void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
479template __declspec(dllimport) void funcTmpl<ExplicitInst_Imported>();
480template __declspec(dllimport) void inlineFuncTmpl<ExplicitInst_Imported>();
481USE(funcTmpl<ExplicitInst_Imported>)
482USE(inlineFuncTmpl<ExplicitInst_Imported>)
483
484
485// Import specialization of a non-imported function template.
486// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_Imported@@@@YAXXZ"()
487// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitSpec_ImportedEvv()
488template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Imported>();
489USE(funcTmpl<ExplicitSpec_Imported>)
490
491// MSC-DAG-FIXME: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
492// MO1-DAG-FIXME: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"()
493#ifdef MSABI
494//template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Def_Imported>() {}
495//USE(funcTmpl<ExplicitSpec_Def_Imported>)
496#endif
497
498// MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
499// GNU-DAG: declare dllimport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
500// MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
501// GO1-DAG: define available_externally dllimport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
502template<> __declspec(dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {}
503USE(funcTmpl<ExplicitSpec_InlineDef_Imported>)
Hans Wennborg853ae942014-05-30 16:59:42 +0000504
505
506
507//===----------------------------------------------------------------------===//
508// Classes
509//===----------------------------------------------------------------------===//
510
511struct __declspec(dllimport) T {
512 void a() {}
513 // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?a@T@@QAEXXZ"
514
515 static int b;
516 // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32
517};
518USEMEMFUNC(T, a)
519USEVAR(T::b)
520
521template <typename T> struct __declspec(dllimport) U { void foo() {} };
522// MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?foo@?$U@H@@QAEXXZ"
523struct __declspec(dllimport) V : public U<int> { };
524USEMEMFUNC(V, foo)
525
526struct __declspec(dllimport) W { virtual void foo() {} };
527USECLASS(W)
528// vftable:
529// 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*)]
530
531struct __declspec(dllimport) X : public virtual W {};
532USECLASS(X)
533// vbtable:
534// MO1-DAG: @"\01??_8X@@7B@" = available_externally dllimport unnamed_addr constant [2 x i32] [i32 0, i32 4]
535
536struct __declspec(dllimport) Y {
537 int x;
538};
539
540struct __declspec(dllimport) Z { virtual ~Z() {} };
541USECLASS(Z)
542// User-defined dtor:
543// MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1Z@@UAE@XZ"
544
545namespace DontUseDtorAlias {
546 struct __declspec(dllimport) A { ~A(); };
547 struct __declspec(dllimport) B : A { ~B(); };
548 inline A::~A() { }
549 inline B::~B() { }
550 // Emit a real definition of B's constructor; don't alias it to A's.
551 // MO1-DAG: available_externally dllimport x86_thiscallcc void @"\01??1B@DontUseDtorAlias@@QAE@XZ"
552 USECLASS(B)
553}
554
555namespace Vtordisp {
556 // Don't dllimport the vtordisp.
557 // MO1-DAG: define weak x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPPPPPM@A@AEXXZ"
558
559 class Base {
560 virtual void f() {}
561 };
562 template <typename T>
563 class __declspec(dllimport) C : virtual public Base {
564 public:
565 C() {}
566 virtual void f() {}
567 };
568 template class C<char>;
569}