Hans Wennborg | 853ae94 | 2014-05-30 16:59:42 +0000 | [diff] [blame] | 1 | // 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 Wennborg | b0f2f14 | 2014-05-15 22:07:49 +0000 | [diff] [blame] | 7 | |
Nico Rieck | 755a36f | 2014-05-25 10:34:16 +0000 | [diff] [blame] | 8 | // Helper structs to make templates more expressive. |
| 9 | struct ImplicitInst_Imported {}; |
| 10 | struct ImplicitInst_NotImported {}; |
| 11 | struct ExplicitDecl_Imported {}; |
| 12 | struct ExplicitInst_Imported {}; |
| 13 | struct ExplicitSpec_Imported {}; |
| 14 | struct ExplicitSpec_Def_Imported {}; |
| 15 | struct ExplicitSpec_InlineDef_Imported {}; |
| 16 | struct ExplicitSpec_NotImported {}; |
Hans Wennborg | b0f2f14 | 2014-05-15 22:07:49 +0000 | [diff] [blame] | 17 | |
Nico Rieck | 755a36f | 2014-05-25 10:34:16 +0000 | [diff] [blame] | 18 | #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 Wennborg | 853ae94 | 2014-05-30 16:59:42 +0000 | [diff] [blame] | 24 | #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; } |
| 25 | #define USECLASS(class) void UNIQ(USE)() { class x; } |
Hans Wennborg | b0f2f14 | 2014-05-15 22:07:49 +0000 | [diff] [blame] | 26 | |
Nico Rieck | 755a36f | 2014-05-25 10:34:16 +0000 | [diff] [blame] | 27 | //===----------------------------------------------------------------------===// |
| 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; |
| 35 | USEVAR(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; |
| 41 | USEVAR(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; |
| 48 | USEVAR(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; |
| 54 | USEVAR(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* |
| 59 | int *__attribute__((dllimport)) GlobalRedecl2b; |
| 60 | int *__attribute__((dllimport)) GlobalRedecl2b; |
| 61 | USEVARTYPE(int*, GlobalRedecl2b) |
| 62 | |
| 63 | // MSC-DAG: @"\01?GlobalRedecl2c@@3HA" = external dllimport global i32 |
| 64 | // GNU-DAG: @GlobalRedecl2c = external dllimport global i32 |
| 65 | int GlobalRedecl2c __attribute__((dllimport)); |
| 66 | int GlobalRedecl2c __attribute__((dllimport)); |
| 67 | USEVAR(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 |
| 75 | USEVAR(GlobalRedecl3) |
| 76 | |
| 77 | // MSC-DAG: @"\01?ExternalGlobal@ns@@3HA" = external dllimport global i32 |
| 78 | // GNU-DAG: @_ZN2ns14ExternalGlobalE = external dllimport global i32 |
| 79 | namespace ns { __declspec(dllimport) int ExternalGlobal; } |
| 80 | USEVAR(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 |
| 91 | template<typename T> __declspec(dllimport) extern int ExternVarTmplDecl; |
| 92 | USEVAR(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 |
| 97 | template<typename T> __declspec(dllimport) int VarTmplDecl; |
| 98 | USEVAR(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 |
| 103 | template<typename T> __declspec(dllimport) extern int VarTmplRedecl1; |
| 104 | template<typename T> __declspec(dllimport) extern int VarTmplRedecl1; |
| 105 | USEVAR(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 |
| 109 | template<typename T> __declspec(dllimport) int VarTmplRedecl2; |
| 110 | template<typename T> __declspec(dllimport) int VarTmplRedecl2; |
| 111 | USEVAR(VarTmplRedecl2<ImplicitInst_Imported>) |
| 112 | |
| 113 | // MSC-DAG: @"\01??$VarTmplRedecl3@UImplicitInst_Imported@@@@3HA" = external global i32 |
| 114 | // GNU-DAG: @_Z14VarTmplRedecl3I21ImplicitInst_ImportedE = external global i32 |
| 115 | template<typename T> __declspec(dllimport) extern int VarTmplRedecl3; |
| 116 | template<typename T> extern int VarTmplRedecl3; // dllimport ignored |
| 117 | USEVAR(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 |
| 122 | namespace ns { template<typename T> __declspec(dllimport) int ExternalVarTmpl; } |
| 123 | USEVAR(ns::ExternalVarTmpl<ImplicitInst_Imported>) |
| 124 | |
| 125 | |
| 126 | template<typename T> int VarTmpl; |
| 127 | template<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 |
| 132 | USEVAR(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 |
| 137 | extern template int ImportedVarTmpl<ExplicitDecl_Imported>; |
| 138 | USEVAR(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 |
| 146 | template<> __declspec(dllimport) int ImportedVarTmpl<ExplicitSpec_Imported>; |
| 147 | USEVAR(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 |
| 153 | template<> int ImportedVarTmpl<ExplicitSpec_NotImported>; |
| 154 | USEVAR(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 |
| 159 | extern template __declspec(dllimport) int VarTmpl<ExplicitDecl_Imported>; |
| 160 | USEVAR(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 |
| 165 | template __declspec(dllimport) int VarTmpl<ExplicitInst_Imported>; |
| 166 | USEVAR(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 |
| 171 | template<> __declspec(dllimport) int VarTmpl<ExplicitSpec_Imported>; |
| 172 | USEVAR(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(); |
| 184 | USE(decl) |
| 185 | |
| 186 | // extern "C" |
| 187 | // MSC-DAG: declare dllimport void @externC() |
| 188 | // GNU-DAG: declare dllimport void @externC() |
| 189 | extern "C" __declspec(dllimport) void externC(); |
| 190 | USE(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() {} |
| 198 | USE(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() {} |
| 206 | USE(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() {} |
| 214 | USE(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() {} |
| 220 | USE(noinline) |
| 221 | |
Nico Rieck | 755a36f | 2014-05-25 10:34:16 +0000 | [diff] [blame] | 222 | // Redeclarations |
| 223 | // MSC-DAG: declare dllimport void @"\01?redecl1@@YAXXZ"() |
| 224 | // GNU-DAG: declare dllimport void @_Z7redecl1v() |
| 225 | __declspec(dllimport) void redecl1(); |
| 226 | __declspec(dllimport) void redecl1(); |
| 227 | USE(redecl1) |
| 228 | |
| 229 | // NB: MSC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC |
| 230 | // and drop the dllimport with a warning. |
| 231 | // MSC-DAG: declare void @"\01?redecl2@@YAXXZ"() |
| 232 | // GNU-DAG: declare void @_Z7redecl2v() |
| 233 | __declspec(dllimport) void redecl2(); |
| 234 | void redecl2(); |
| 235 | USE(redecl2) |
| 236 | |
| 237 | // MSC-DAG: define void @"\01?redecl3@@YAXXZ"() |
| 238 | // GNU-DAG: define void @_Z7redecl3v() |
| 239 | __declspec(dllimport) void redecl3(); |
| 240 | void redecl3() {} // dllimport ignored |
| 241 | USE(redecl3) |
| 242 | |
| 243 | |
| 244 | // Friend functions |
| 245 | // MSC-DAG: declare dllimport void @"\01?friend1@@YAXXZ"() |
| 246 | // GNU-DAG: declare dllimport void @_Z7friend1v() |
| 247 | // MSC-DAG: declare void @"\01?friend2@@YAXXZ"() |
| 248 | // GNU-DAG: declare void @_Z7friend2v() |
| 249 | // MSC-DAG: define void @"\01?friend3@@YAXXZ"() |
| 250 | // GNU-DAG: define void @_Z7friend3v() |
| 251 | struct FuncFriend { |
| 252 | friend __declspec(dllimport) void friend1(); |
| 253 | friend __declspec(dllimport) void friend2(); |
| 254 | friend __declspec(dllimport) void friend3(); |
Hans Wennborg | b0f2f14 | 2014-05-15 22:07:49 +0000 | [diff] [blame] | 255 | }; |
Nico Rieck | 755a36f | 2014-05-25 10:34:16 +0000 | [diff] [blame] | 256 | __declspec(dllimport) void friend1(); |
| 257 | void friend2(); // dllimport ignored |
| 258 | void friend3() {} // dllimport ignored |
| 259 | USE(friend1) |
| 260 | USE(friend2) |
| 261 | USE(friend3) |
Hans Wennborg | b0f2f14 | 2014-05-15 22:07:49 +0000 | [diff] [blame] | 262 | |
Nico Rieck | 755a36f | 2014-05-25 10:34:16 +0000 | [diff] [blame] | 263 | // Implicit declarations can be redeclared with dllimport. |
| 264 | // MSC-DAG: declare dllimport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"( |
| 265 | // GNU-DAG: declare dllimport noalias i8* @_Znw{{[yj]}}( |
| 266 | __declspec(dllimport) void* operator new(__SIZE_TYPE__ n); |
| 267 | void UNIQ(use)() { ::operator new(42); } |
| 268 | |
| 269 | // MSC-DAG: declare dllimport void @"\01?externalFunc@ns@@YAXXZ"() |
| 270 | // GNU-DAG: declare dllimport void @_ZN2ns12externalFuncEv() |
| 271 | namespace ns { __declspec(dllimport) void externalFunc(); } |
| 272 | USE(ns::externalFunc) |
| 273 | |
| 274 | |
| 275 | |
| 276 | //===----------------------------------------------------------------------===// |
| 277 | // Function templates |
| 278 | //===----------------------------------------------------------------------===// |
| 279 | |
| 280 | // Import function template declaration. |
| 281 | // MSC-DAG: declare dllimport void @"\01??$funcTmplDecl@UImplicitInst_Imported@@@@YAXXZ"() |
| 282 | // GNU-DAG: declare dllimport void @_Z12funcTmplDeclI21ImplicitInst_ImportedEvv() |
| 283 | template<typename T> __declspec(dllimport) void funcTmplDecl(); |
| 284 | USE(funcTmplDecl<ImplicitInst_Imported>) |
| 285 | |
| 286 | // Function template definitions cannot be imported. |
| 287 | |
| 288 | // Import inline function template. |
| 289 | // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"() |
| 290 | // GNU-DAG: declare dllimport void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv() |
| 291 | // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"() |
| 292 | // GO1-DAG: define available_externally dllimport void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv() |
| 293 | template<typename T> __declspec(dllimport) inline void inlineFuncTmpl1() {} |
| 294 | USE(inlineFuncTmpl1<ImplicitInst_Imported>) |
| 295 | |
| 296 | // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"() |
| 297 | // GNU-DAG: declare dllimport void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv() |
| 298 | // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"() |
| 299 | // GO1-DAG: define available_externally dllimport void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv() |
| 300 | template<typename T> inline void __attribute__((dllimport)) inlineFuncTmpl2() {} |
| 301 | USE(inlineFuncTmpl2<ImplicitInst_Imported>) |
| 302 | |
| 303 | // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"() |
| 304 | // GNU-DAG: declare dllimport void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv() |
| 305 | // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"() |
| 306 | // GO1-DAG: define available_externally dllimport void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv() |
| 307 | template<typename T> __declspec(dllimport) inline void inlineFuncTmplDecl(); |
| 308 | template<typename T> void inlineFuncTmplDecl() {} |
| 309 | USE(inlineFuncTmplDecl<ImplicitInst_Imported>) |
| 310 | |
| 311 | // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"() |
| 312 | // GNU-DAG: declare dllimport void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv() |
| 313 | // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"() |
| 314 | // GO1-DAG: define available_externally dllimport void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv() |
| 315 | template<typename T> __declspec(dllimport) void inlineFuncTmplDef(); |
| 316 | template<typename T> inline void inlineFuncTmplDef() {} |
| 317 | USE(inlineFuncTmplDef<ImplicitInst_Imported>) |
| 318 | |
| 319 | |
| 320 | // Redeclarations |
| 321 | // MSC-DAG: declare dllimport void @"\01??$funcTmplRedecl1@UImplicitInst_Imported@@@@YAXXZ"() |
| 322 | // GNU-DAG: declare dllimport void @_Z15funcTmplRedecl1I21ImplicitInst_ImportedEvv() |
| 323 | template<typename T> __declspec(dllimport) void funcTmplRedecl1(); |
| 324 | template<typename T> __declspec(dllimport) void funcTmplRedecl1(); |
| 325 | USE(funcTmplRedecl1<ImplicitInst_Imported>) |
| 326 | |
| 327 | // MSC-DAG: declare void @"\01??$funcTmplRedecl2@UImplicitInst_NotImported@@@@YAXXZ"() |
| 328 | // GNU-DAG: declare void @_Z15funcTmplRedecl2I24ImplicitInst_NotImportedEvv() |
| 329 | template<typename T> __declspec(dllimport) void funcTmplRedecl2(); |
| 330 | template<typename T> void funcTmplRedecl2(); // dllimport ignored |
| 331 | USE(funcTmplRedecl2<ImplicitInst_NotImported>) |
| 332 | |
| 333 | // MSC-DAG: define linkonce_odr void @"\01??$funcTmplRedecl3@UImplicitInst_NotImported@@@@YAXXZ"() |
| 334 | // GNU-DAG: define linkonce_odr void @_Z15funcTmplRedecl3I24ImplicitInst_NotImportedEvv() |
| 335 | template<typename T> __declspec(dllimport) void funcTmplRedecl3(); |
| 336 | template<typename T> void funcTmplRedecl3() {} // dllimport ignored |
| 337 | USE(funcTmplRedecl3<ImplicitInst_NotImported>) |
| 338 | |
| 339 | |
| 340 | // Function template friends |
| 341 | // MSC-DAG: declare dllimport void @"\01??$funcTmplFriend1@UImplicitInst_Imported@@@@YAXXZ"() |
| 342 | // GNU-DAG: declare dllimport void @_Z15funcTmplFriend1I21ImplicitInst_ImportedEvv() |
| 343 | // MSC-DAG: declare void @"\01??$funcTmplFriend2@UImplicitInst_NotImported@@@@YAXXZ"() |
| 344 | // GNU-DAG: declare void @_Z15funcTmplFriend2I24ImplicitInst_NotImportedEvv() |
| 345 | // MSC-DAG: define linkonce_odr void @"\01??$funcTmplFriend3@UImplicitInst_NotImported@@@@YAXXZ"() |
| 346 | // GNU-DAG: define linkonce_odr void @_Z15funcTmplFriend3I24ImplicitInst_NotImportedEvv() |
| 347 | // MSC-DAG: declare dllimport void @"\01??$funcTmplFriend4@UImplicitInst_Imported@@@@YAXXZ"() |
| 348 | // GNU-DAG: declare dllimport void @_Z15funcTmplFriend4I21ImplicitInst_ImportedEvv() |
| 349 | struct FuncTmplFriend { |
| 350 | template<typename T> friend __declspec(dllimport) void funcTmplFriend1(); |
| 351 | template<typename T> friend __declspec(dllimport) void funcTmplFriend2(); |
| 352 | template<typename T> friend __declspec(dllimport) void funcTmplFriend3(); |
| 353 | template<typename T> friend __declspec(dllimport) inline void funcTmplFriend4(); |
| 354 | }; |
| 355 | template<typename T> __declspec(dllimport) void funcTmplFriend1(); |
| 356 | template<typename T> void funcTmplFriend2(); // dllimport ignored |
| 357 | template<typename T> void funcTmplFriend3() {} // dllimport ignored |
| 358 | template<typename T> inline void funcTmplFriend4() {} |
| 359 | USE(funcTmplFriend1<ImplicitInst_Imported>) |
| 360 | USE(funcTmplFriend2<ImplicitInst_NotImported>) |
| 361 | USE(funcTmplFriend3<ImplicitInst_NotImported>) |
| 362 | USE(funcTmplFriend4<ImplicitInst_Imported>) |
| 363 | |
| 364 | // MSC-DAG: declare dllimport void @"\01??$externalFuncTmpl@UImplicitInst_Imported@@@ns@@YAXXZ"() |
| 365 | // GNU-DAG: declare dllimport void @_ZN2ns16externalFuncTmplI21ImplicitInst_ImportedEEvv() |
| 366 | namespace ns { template<typename T> __declspec(dllimport) void externalFuncTmpl(); } |
| 367 | USE(ns::externalFuncTmpl<ImplicitInst_Imported>) |
| 368 | |
| 369 | |
| 370 | template<typename T> void funcTmpl() {} |
| 371 | template<typename T> inline void inlineFuncTmpl() {} |
| 372 | template<typename T> __declspec(dllimport) void importedFuncTmplDecl(); |
| 373 | template<typename T> __declspec(dllimport) inline void importedFuncTmpl() {} |
| 374 | |
| 375 | // Import implicit instantiation of an imported function template. |
| 376 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"() |
| 377 | // GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI21ImplicitInst_ImportedEvv() |
| 378 | USE(importedFuncTmplDecl<ImplicitInst_Imported>) |
| 379 | |
| 380 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"() |
| 381 | // GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv() |
| 382 | // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"() |
| 383 | // GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv() |
| 384 | USE(importedFuncTmpl<ImplicitInst_Imported>) |
| 385 | |
| 386 | // Import explicit instantiation declaration of an imported function template. |
| 387 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"() |
| 388 | // GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv() |
| 389 | // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"() |
| 390 | // GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv() |
| 391 | extern template void importedFuncTmpl<ExplicitDecl_Imported>(); |
| 392 | USE(importedFuncTmpl<ExplicitDecl_Imported>) |
| 393 | |
| 394 | // Import explicit instantiation definition of an imported function template. |
| 395 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"() |
| 396 | // GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv() |
| 397 | // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"() |
| 398 | // GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv() |
| 399 | template void importedFuncTmpl<ExplicitInst_Imported>(); |
| 400 | USE(importedFuncTmpl<ExplicitInst_Imported>) |
| 401 | |
| 402 | |
| 403 | // Import specialization of an imported function template. |
| 404 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Imported@@@@YAXXZ"() |
| 405 | // GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI21ExplicitSpec_ImportedEvv() |
| 406 | template<> __declspec(dllimport) void importedFuncTmplDecl<ExplicitSpec_Imported>(); |
| 407 | USE(importedFuncTmplDecl<ExplicitSpec_Imported>) |
| 408 | |
| 409 | // MSC-DAG-FIXME: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Def_Imported@@@@YAXXZ"() |
| 410 | // MO1-DAG-FIXME: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_Def_Imported@@@@YAXXZ"() |
| 411 | #ifdef MSABI |
| 412 | //template<> __declspec(dllimport) void importedFuncTmplDecl<ExplicitSpec_Def_Imported>() {} |
| 413 | //USE(importedFuncTmplDecl<ExplicitSpec_Def_Imported>) |
| 414 | #endif |
| 415 | |
| 416 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"() |
| 417 | // GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv() |
| 418 | // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"() |
| 419 | // GO1-DAG: define available_externally dllimport void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv() |
| 420 | template<> __declspec(dllimport) inline void importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>() {} |
| 421 | USE(importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>) |
| 422 | |
| 423 | |
| 424 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Imported@@@@YAXXZ"() |
| 425 | // GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitSpec_ImportedEvv() |
| 426 | template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Imported>(); |
| 427 | USE(importedFuncTmpl<ExplicitSpec_Imported>) |
| 428 | |
| 429 | // MSC-DAG-FIXME: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"() |
| 430 | // MO1-DAG-FIXME: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"() |
| 431 | #ifdef MSABI |
| 432 | //template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Def_Imported>() {} |
| 433 | //USE(importedFuncTmpl<ExplicitSpec_Def_Imported>) |
| 434 | #endif |
| 435 | |
| 436 | // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"() |
| 437 | // GNU-DAG: declare dllimport void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv() |
| 438 | // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"() |
| 439 | // GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv() |
| 440 | template<> __declspec(dllimport) inline void importedFuncTmpl<ExplicitSpec_InlineDef_Imported>() {} |
| 441 | USE(importedFuncTmpl<ExplicitSpec_InlineDef_Imported>) |
| 442 | |
| 443 | |
| 444 | // Not importing specialization of an imported function template without |
| 445 | // explicit dllimport. |
| 446 | // MSC-DAG: define void @"\01??$importedFuncTmpl@UExplicitSpec_NotImported@@@@YAXXZ"() |
| 447 | // GNU-DAG: define void @_Z16importedFuncTmplI24ExplicitSpec_NotImportedEvv() |
| 448 | template<> void importedFuncTmpl<ExplicitSpec_NotImported>() {} |
| 449 | USE(importedFuncTmpl<ExplicitSpec_NotImported>) |
| 450 | |
| 451 | |
| 452 | // Import explicit instantiation declaration of a non-imported function template. |
| 453 | // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitDecl_Imported@@@@YAXXZ"() |
| 454 | // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"() |
| 455 | // GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitDecl_ImportedEvv() |
| 456 | // GNU-DAG: declare dllimport void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv() |
| 457 | // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"() |
| 458 | // GO1-DAG: define available_externally dllimport void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv() |
| 459 | extern template __declspec(dllimport) void funcTmpl<ExplicitDecl_Imported>(); |
| 460 | extern template __declspec(dllimport) void inlineFuncTmpl<ExplicitDecl_Imported>(); |
| 461 | USE(funcTmpl<ExplicitDecl_Imported>) |
| 462 | USE(inlineFuncTmpl<ExplicitDecl_Imported>) |
| 463 | |
| 464 | |
| 465 | // Import explicit instantiation definition of a non-imported function template. |
| 466 | // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"() |
| 467 | // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"() |
| 468 | // GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv() |
| 469 | // GNU-DAG: declare dllimport void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv() |
| 470 | // MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"() |
| 471 | // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"() |
| 472 | // GO1-DAG: define available_externally dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv() |
| 473 | // GO1-DAG: define available_externally dllimport void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv() |
| 474 | template __declspec(dllimport) void funcTmpl<ExplicitInst_Imported>(); |
| 475 | template __declspec(dllimport) void inlineFuncTmpl<ExplicitInst_Imported>(); |
| 476 | USE(funcTmpl<ExplicitInst_Imported>) |
| 477 | USE(inlineFuncTmpl<ExplicitInst_Imported>) |
| 478 | |
| 479 | |
| 480 | // Import specialization of a non-imported function template. |
| 481 | // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_Imported@@@@YAXXZ"() |
| 482 | // GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitSpec_ImportedEvv() |
| 483 | template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Imported>(); |
| 484 | USE(funcTmpl<ExplicitSpec_Imported>) |
| 485 | |
| 486 | // MSC-DAG-FIXME: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"() |
| 487 | // MO1-DAG-FIXME: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_Def_Imported@@@@YAXXZ"() |
| 488 | #ifdef MSABI |
| 489 | //template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Def_Imported>() {} |
| 490 | //USE(funcTmpl<ExplicitSpec_Def_Imported>) |
| 491 | #endif |
| 492 | |
| 493 | // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"() |
| 494 | // GNU-DAG: declare dllimport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv() |
| 495 | // MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"() |
| 496 | // GO1-DAG: define available_externally dllimport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv() |
| 497 | template<> __declspec(dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {} |
| 498 | USE(funcTmpl<ExplicitSpec_InlineDef_Imported>) |
Hans Wennborg | 853ae94 | 2014-05-30 16:59:42 +0000 | [diff] [blame] | 499 | |
| 500 | |
| 501 | |
| 502 | //===----------------------------------------------------------------------===// |
| 503 | // Classes |
| 504 | //===----------------------------------------------------------------------===// |
| 505 | |
| 506 | struct __declspec(dllimport) T { |
| 507 | void a() {} |
| 508 | // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?a@T@@QAEXXZ" |
| 509 | |
| 510 | static int b; |
| 511 | // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32 |
| 512 | }; |
| 513 | USEMEMFUNC(T, a) |
| 514 | USEVAR(T::b) |
| 515 | |
| 516 | template <typename T> struct __declspec(dllimport) U { void foo() {} }; |
| 517 | // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?foo@?$U@H@@QAEXXZ" |
| 518 | struct __declspec(dllimport) V : public U<int> { }; |
| 519 | USEMEMFUNC(V, foo) |
| 520 | |
| 521 | struct __declspec(dllimport) W { virtual void foo() {} }; |
| 522 | USECLASS(W) |
| 523 | // vftable: |
| 524 | // 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 Wennborg | da24e9c | 2014-06-02 23:13:03 +0000 | [diff] [blame^] | 525 | // GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)] |
| 526 | |
| 527 | struct __declspec(dllimport) KeyFuncClass { |
| 528 | constexpr KeyFuncClass() {} |
| 529 | virtual void foo(); |
| 530 | }; |
| 531 | constexpr KeyFuncClass keyFuncClassVar; |
| 532 | // G32-DAG: @_ZTV12KeyFuncClass = external dllimport unnamed_addr constant [3 x i8*] |
Hans Wennborg | 853ae94 | 2014-05-30 16:59:42 +0000 | [diff] [blame] | 533 | |
| 534 | struct __declspec(dllimport) X : public virtual W {}; |
| 535 | USECLASS(X) |
| 536 | // vbtable: |
| 537 | // MO1-DAG: @"\01??_8X@@7B@" = available_externally dllimport unnamed_addr constant [2 x i32] [i32 0, i32 4] |
| 538 | |
| 539 | struct __declspec(dllimport) Y { |
| 540 | int x; |
| 541 | }; |
| 542 | |
| 543 | struct __declspec(dllimport) Z { virtual ~Z() {} }; |
| 544 | USECLASS(Z) |
| 545 | // User-defined dtor: |
| 546 | // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1Z@@UAE@XZ" |
| 547 | |
| 548 | namespace DontUseDtorAlias { |
| 549 | struct __declspec(dllimport) A { ~A(); }; |
| 550 | struct __declspec(dllimport) B : A { ~B(); }; |
| 551 | inline A::~A() { } |
| 552 | inline B::~B() { } |
| 553 | // Emit a real definition of B's constructor; don't alias it to A's. |
| 554 | // MO1-DAG: available_externally dllimport x86_thiscallcc void @"\01??1B@DontUseDtorAlias@@QAE@XZ" |
| 555 | USECLASS(B) |
| 556 | } |
| 557 | |
| 558 | namespace Vtordisp { |
| 559 | // Don't dllimport the vtordisp. |
| 560 | // MO1-DAG: define weak x86_thiscallcc void @"\01?f@?$C@D@Vtordisp@@$4PPPPPPPM@A@AEXXZ" |
| 561 | |
| 562 | class Base { |
| 563 | virtual void f() {} |
| 564 | }; |
| 565 | template <typename T> |
| 566 | class __declspec(dllimport) C : virtual public Base { |
| 567 | public: |
| 568 | C() {} |
| 569 | virtual void f() {} |
| 570 | }; |
| 571 | template class C<char>; |
| 572 | } |
Hans Wennborg | da24e9c | 2014-06-02 23:13:03 +0000 | [diff] [blame^] | 573 | |
| 574 | //===----------------------------------------------------------------------===// |
| 575 | // Negative checks |
| 576 | //===----------------------------------------------------------------------===// |
| 577 | |
| 578 | // These checks are at the end to avoid interference with the DAG checks. |
| 579 | |
| 580 | // MSC-NOT: @"\01?alwaysInline@@YAXXZ"() |
| 581 | // GNU-NOT: @_Z12alwaysInlinev() |
| 582 | __declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {} |
| 583 | USE(alwaysInline) |