head 1.1; branch 1.1.1; access; symbols netbsd-11-0-RELEASE:1.1.1.9 netbsd-11-0-RC7:1.1.1.9 netbsd-11-0-RC6:1.1.1.9 netbsd-11-0-RC5:1.1.1.9 netbsd-11-0-RC4:1.1.1.9 netbsd-11-0-RC3:1.1.1.9 netbsd-11-0-RC2:1.1.1.9 netbsd-11-0-RC1:1.1.1.9 perseant-exfatfs-base-20250801:1.1.1.9 netbsd-11:1.1.1.9.0.10 netbsd-11-base:1.1.1.9 netbsd-10-1-RELEASE:1.1.1.9 perseant-exfatfs-base-20240630:1.1.1.9 perseant-exfatfs:1.1.1.9.0.8 perseant-exfatfs-base:1.1.1.9 netbsd-8-3-RELEASE:1.1.1.6 netbsd-9-4-RELEASE:1.1.1.8 netbsd-10-0-RELEASE:1.1.1.9 netbsd-10-0-RC6:1.1.1.9 netbsd-10-0-RC5:1.1.1.9 netbsd-10-0-RC4:1.1.1.9 netbsd-10-0-RC3:1.1.1.9 netbsd-10-0-RC2:1.1.1.9 netbsd-10-0-RC1:1.1.1.9 netbsd-10:1.1.1.9.0.6 netbsd-10-base:1.1.1.9 netbsd-9-3-RELEASE:1.1.1.8 cjep_sun2x:1.1.1.9.0.4 cjep_sun2x-base:1.1.1.9 cjep_staticlib_x-base1:1.1.1.9 netbsd-9-2-RELEASE:1.1.1.8 cjep_staticlib_x:1.1.1.9.0.2 cjep_staticlib_x-base:1.1.1.9 netbsd-9-1-RELEASE:1.1.1.8 phil-wifi-20200421:1.1.1.9 phil-wifi-20200411:1.1.1.9 phil-wifi-20200406:1.1.1.9 netbsd-8-2-RELEASE:1.1.1.6 netbsd-9-0-RELEASE:1.1.1.8 netbsd-9-0-RC2:1.1.1.8 netbsd-9-0-RC1:1.1.1.8 netbsd-9:1.1.1.8.0.2 netbsd-9-base:1.1.1.8 phil-wifi-20190609:1.1.1.8 netbsd-8-1-RELEASE:1.1.1.6 netbsd-8-1-RC1:1.1.1.6 pgoyette-compat-merge-20190127:1.1.1.7.2.1 pgoyette-compat-20190127:1.1.1.8 pgoyette-compat-20190118:1.1.1.8 pgoyette-compat-1226:1.1.1.8 pgoyette-compat-1126:1.1.1.8 pgoyette-compat-1020:1.1.1.8 pgoyette-compat-0930:1.1.1.8 pgoyette-compat-0906:1.1.1.8 netbsd-7-2-RELEASE:1.1.1.3.2.1 pgoyette-compat-0728:1.1.1.8 clang-337282:1.1.1.8 netbsd-8-0-RELEASE:1.1.1.6 phil-wifi:1.1.1.7.0.4 phil-wifi-base:1.1.1.7 pgoyette-compat-0625:1.1.1.7 netbsd-8-0-RC2:1.1.1.6 pgoyette-compat-0521:1.1.1.7 pgoyette-compat-0502:1.1.1.7 pgoyette-compat-0422:1.1.1.7 netbsd-8-0-RC1:1.1.1.6 pgoyette-compat-0415:1.1.1.7 pgoyette-compat-0407:1.1.1.7 pgoyette-compat-0330:1.1.1.7 pgoyette-compat-0322:1.1.1.7 pgoyette-compat-0315:1.1.1.7 netbsd-7-1-2-RELEASE:1.1.1.3.2.1 pgoyette-compat:1.1.1.7.0.2 pgoyette-compat-base:1.1.1.7 netbsd-7-1-1-RELEASE:1.1.1.3.2.1 clang-319952:1.1.1.7 matt-nb8-mediatek:1.1.1.6.0.10 matt-nb8-mediatek-base:1.1.1.6 clang-309604:1.1.1.7 perseant-stdc-iso10646:1.1.1.6.0.8 perseant-stdc-iso10646-base:1.1.1.6 netbsd-8:1.1.1.6.0.6 netbsd-8-base:1.1.1.6 prg-localcount2-base3:1.1.1.6 prg-localcount2-base2:1.1.1.6 prg-localcount2-base1:1.1.1.6 prg-localcount2:1.1.1.6.0.4 prg-localcount2-base:1.1.1.6 pgoyette-localcount-20170426:1.1.1.6 bouyer-socketcan-base1:1.1.1.6 pgoyette-localcount-20170320:1.1.1.6 netbsd-7-1:1.1.1.3.2.1.0.6 netbsd-7-1-RELEASE:1.1.1.3.2.1 netbsd-7-1-RC2:1.1.1.3.2.1 clang-294123:1.1.1.6 netbsd-7-nhusb-base-20170116:1.1.1.3.2.1 bouyer-socketcan:1.1.1.6.0.2 bouyer-socketcan-base:1.1.1.6 clang-291444:1.1.1.6 pgoyette-localcount-20170107:1.1.1.5 netbsd-7-1-RC1:1.1.1.3.2.1 pgoyette-localcount-20161104:1.1.1.5 netbsd-7-0-2-RELEASE:1.1.1.3.2.1 localcount-20160914:1.1.1.5 netbsd-7-nhusb:1.1.1.3.2.1.0.4 netbsd-7-nhusb-base:1.1.1.3.2.1 clang-280599:1.1.1.5 pgoyette-localcount-20160806:1.1.1.5 pgoyette-localcount-20160726:1.1.1.5 pgoyette-localcount:1.1.1.5.0.2 pgoyette-localcount-base:1.1.1.5 netbsd-7-0-1-RELEASE:1.1.1.3.2.1 clang-261930:1.1.1.5 netbsd-7-0:1.1.1.3.2.1.0.2 netbsd-7-0-RELEASE:1.1.1.3.2.1 netbsd-7-0-RC3:1.1.1.3.2.1 netbsd-7-0-RC2:1.1.1.3.2.1 netbsd-7-0-RC1:1.1.1.3.2.1 clang-237755:1.1.1.4 clang-232565:1.1.1.4 clang-227398:1.1.1.4 tls-maxphys-base:1.1.1.3 tls-maxphys:1.1.1.3.0.4 netbsd-7:1.1.1.3.0.2 netbsd-7-base:1.1.1.3 clang-215315:1.1.1.3 clang-209886:1.1.1.2 yamt-pagecache:1.1.1.1.0.4 yamt-pagecache-base9:1.1.1.1 tls-earlyentropy:1.1.1.1.0.2 tls-earlyentropy-base:1.1.1.2 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.1 riastradh-drm2-base3:1.1.1.1 clang-202566:1.1.1.1 LLVM:1.1.1; locks; strict; comment @// @; 1.1 date 2014.03.04.19.56.08; author joerg; state Exp; branches 1.1.1.1; next ; commitid 29z1hJonZISIXprx; 1.1.1.1 date 2014.03.04.19.56.08; author joerg; state Exp; branches 1.1.1.1.2.1 1.1.1.1.4.1; next 1.1.1.2; commitid 29z1hJonZISIXprx; 1.1.1.2 date 2014.05.30.18.14.49; author joerg; state Exp; branches; next 1.1.1.3; commitid 8q0kdlBlCn09GACx; 1.1.1.3 date 2014.08.10.17.08.44; author joerg; state Exp; branches 1.1.1.3.2.1 1.1.1.3.4.1; next 1.1.1.4; commitid N85tXAN6Ex9VZPLx; 1.1.1.4 date 2015.01.29.19.57.37; author joerg; state Exp; branches; next 1.1.1.5; commitid mlISSizlPKvepX7y; 1.1.1.5 date 2016.02.27.22.10.17; author joerg; state Exp; branches 1.1.1.5.2.1; next 1.1.1.6; commitid tIimz3oDlh1NpBWy; 1.1.1.6 date 2017.01.11.10.37.42; author joerg; state Exp; branches; next 1.1.1.7; commitid CNnUNfII1jgNmxBz; 1.1.1.7 date 2017.08.01.19.34.19; author joerg; state Exp; branches 1.1.1.7.2.1 1.1.1.7.4.1; next 1.1.1.8; commitid pMuDy65V0VicSx1A; 1.1.1.8 date 2018.07.17.18.31.35; author joerg; state Exp; branches; next 1.1.1.9; commitid wDzL46ALjrCZgwKA; 1.1.1.9 date 2019.11.13.22.22.55; author joerg; state dead; branches; next ; commitid QD8YATxuNG34YJKB; 1.1.1.1.2.1 date 2014.08.10.07.08.23; author tls; state Exp; branches; next ; commitid t01A1TLTYxkpGMLx; 1.1.1.1.4.1 date 2014.03.04.19.56.08; author yamt; state dead; branches; next 1.1.1.1.4.2; commitid WSrDtL5nYAUyiyBx; 1.1.1.1.4.2 date 2014.05.22.16.19.40; author yamt; state Exp; branches; next ; commitid WSrDtL5nYAUyiyBx; 1.1.1.3.2.1 date 2015.06.04.20.04.44; author snj; state Exp; branches; next ; commitid yRnjq9fueSo6n9oy; 1.1.1.3.4.1 date 2014.08.10.17.08.44; author tls; state dead; branches; next 1.1.1.3.4.2; commitid jTnpym9Qu0o4R1Nx; 1.1.1.3.4.2 date 2014.08.19.23.49.18; author tls; state Exp; branches; next ; commitid jTnpym9Qu0o4R1Nx; 1.1.1.5.2.1 date 2017.03.20.06.53.33; author pgoyette; state Exp; branches; next ; commitid jjw7cAwgyKq7RfKz; 1.1.1.7.2.1 date 2018.07.28.04.34.11; author pgoyette; state Exp; branches; next ; commitid 1UP1xAIUxv1ZgRLA; 1.1.1.7.4.1 date 2019.06.10.21.46.35; author christos; state Exp; branches; next 1.1.1.7.4.2; commitid jtc8rnCzWiEEHGqB; 1.1.1.7.4.2 date 2020.04.13.07.50.22; author martin; state dead; branches; next ; commitid X01YhRUPVUDaec4C; desc @@ 1.1 log @Initial revision @ text @// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c++11 %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c++1y %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c++1y %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 %s // Helper structs to make templates more expressive. struct ImplicitInst_Imported {}; struct ExplicitDecl_Imported {}; struct ExplicitInst_Imported {}; struct ExplicitSpec_Imported {}; struct ExplicitSpec_Def_Imported {}; struct ExplicitSpec_InlineDef_Imported {}; struct ExplicitSpec_NotImported {}; // Invalid usage. __declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables and functions}} typedef __declspec(dllimport) int typedef2; // expected-warning{{'dllimport' attribute only applies to variables and functions}} typedef int __declspec(dllimport) typedef3; // expected-warning{{'dllimport' attribute only applies to variables and functions}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning{{'dllimport' attribute only applies to variables and functions}} enum __declspec(dllimport) Enum {}; // expected-warning{{'dllimport' attribute only applies to variables and functions}} #if __has_feature(cxx_strong_enums) enum class __declspec(dllimport) EnumClass {}; // expected-warning{{'dllimport' attribute only applies to variables and functions}} #endif //===----------------------------------------------------------------------===// // Globals //===----------------------------------------------------------------------===// // Import declaration. __declspec(dllimport) extern int ExternGlobalDecl; // dllimport implies a declaration. __declspec(dllimport) int GlobalDecl; // Not allowed on definitions. __declspec(dllimport) extern int ExternGlobalInit = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) int GlobalInit1 = 1; // expected-error{{definition of dllimport data}} int __declspec(dllimport) GlobalInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. __declspec(dllimport) extern int ExternGlobalDeclInit; int ExternGlobalDeclInit = 1; // expected-error{{definition of dllimport data}} // Redeclarations __declspec(dllimport) extern int GlobalRedecl1; __declspec(dllimport) extern int GlobalRedecl1; // Import in local scope. void functionScope() { __declspec(dllimport) int LocalVarDecl; __declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) extern int ExternLocalVarDecl; __declspec(dllimport) extern int ExternLocalVarDef = 1; // expected-error{{definition of dllimport data}} } //===----------------------------------------------------------------------===// // Functions //===----------------------------------------------------------------------===// // Import function declaration. Check different placements. __attribute__((dllimport)) void decl1A(); // Sanity check with __attribute__ __declspec(dllimport) void decl1B(); void __attribute__((dllimport)) decl2A(); void __declspec(dllimport) decl2B(); // Not allowed on function definitions. __declspec(dllimport) void def() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}} // extern "C" extern "C" __declspec(dllexport) void externC(); // Import inline function. __declspec(dllimport) inline void inlineFunc1() {} // expected-warning{{'dllimport' attribute ignored}} inline void __attribute__((dllimport)) inlineFunc2() {} // expected-warning{{'dllimport' attribute ignored}} // Redeclarations __declspec(dllimport) void redecl1(); __declspec(dllimport) void redecl1(); __declspec(dllimport) void redecl3(); void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} //===----------------------------------------------------------------------===// // Function templates //===----------------------------------------------------------------------===// // Import function template declaration. Check different placements. template __declspec(dllimport) void funcTmplDecl1(); template void __declspec(dllimport) funcTmplDecl2(); // Redeclarations template __declspec(dllimport) void funcTmplRedecl1(); template __declspec(dllimport) void funcTmplRedecl1(); template __declspec(dllimport) void funcTmplRedecl2(); template void funcTmplRedecl2(); template __declspec(dllimport) void funcTmplRedecl3(); template void funcTmplRedecl3() {} // expected-warning{{'funcTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmpl() {} template __declspec(dllimport) void importedFuncTmpl(); // Import specialization of an imported function template. A definition must be // declared inline. template<> __declspec(dllimport) void importedFuncTmpl(); template<> __declspec(dllimport) void importedFuncTmpl() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}} template<> __declspec(dllimport) inline void importedFuncTmpl() {} // expected-warning{{'dllimport' attribute ignored}} // Not importing specialization of an imported function template without // explicit dllimport. template<> void importedFuncTmpl() {} // Import explicit instantiation declaration of a non-imported function template. extern template __declspec(dllimport) void funcTmpl(); // Import specialization of a non-imported function template. A definition must // be declared inline. template<> __declspec(dllimport) void funcTmpl(); template<> __declspec(dllimport) void funcTmpl() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}} template<> __declspec(dllimport) inline void funcTmpl() {} // expected-warning{{'dllimport' attribute ignored}} @ 1.1.1.1 log @Import Clang 3.5svn r202566. @ text @@ 1.1.1.1.2.1 log @Rebase. @ text @a13 1 namespace { struct Internal {}; } a36 2 int **__attribute__((dllimport))* GlobalDeclChunkAttr; int GlobalDeclAttr __attribute__((dllimport)); d44 2 a45 11 __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int ExternGlobalDeclInit = 1; // expected-warning{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclInit = 1; // expected-warning{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int *GlobalDeclChunkAttrInit = 0; // expected-warning{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclAttrInit = 1; // expected-warning{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} a50 26 __declspec(dllimport) int GlobalRedecl2a; __declspec(dllimport) int GlobalRedecl2a; int *__attribute__((dllimport)) GlobalRedecl2b; int *__attribute__((dllimport)) GlobalRedecl2b; int GlobalRedecl2c __attribute__((dllimport)); int GlobalRedecl2c __attribute__((dllimport)); // NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} extern int GlobalRedecl4; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) int ExternalGlobal; } __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}} // expected-error@@-1{{definition of dllimport data}} a51 3 __declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}} a52 4 __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}} int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}} int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redefinition of 'LocalRedecl3' with a different type: 'int' vs 'float'}} a56 1 __declspec(dllimport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllimport'}} a61 80 // Variable templates //===----------------------------------------------------------------------===// #if __has_feature(cxx_variable_templates) // Import declaration. template __declspec(dllimport) extern int ExternVarTmplDecl; // dllimport implies a declaration. template __declspec(dllimport) int VarTmplDecl; // Not allowed on definitions. template __declspec(dllimport) extern int ExternVarTmplInit = 1; // expected-error{{definition of dllimport data}} template __declspec(dllimport) int VarTmplInit1 = 1; // expected-error{{definition of dllimport data}} template int __declspec(dllimport) VarTmplInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. template __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template int ExternVarTmplDeclInit = 1; // expected-warning{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) int VarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template int VarTmplDeclInit = 1; // expected-warning{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations template __declspec(dllimport) extern int VarTmplRedecl1; template __declspec(dllimport) extern int VarTmplRedecl1; template __declspec(dllimport) int VarTmplRedecl2; template __declspec(dllimport) int VarTmplRedecl2; template __declspec(dllimport) extern int VarTmplRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template extern int VarTmplRedecl3; // expected-warning{{'VarTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template extern int VarTmplRedecl4; // expected-note{{previous declaration is here}} template __declspec(dllimport) extern int VarTmplRedecl4; // expected-error{{redeclaration of 'VarTmplRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. template __declspec(dllimport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllimport'}} template __declspec(dllimport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllimport'}} namespace { template __declspec(dllimport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template __declspec(dllimport) int ExternalVarTmpl; } template __declspec(dllimport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{definition of dllimport data}} // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllimport'}} template int VarTmpl; template __declspec(dllimport) int ImportedVarTmpl; // Import implicit instantiation of an imported variable template. int useVarTmpl() { return ImportedVarTmpl; } // Import explicit instantiation declaration of an imported variable template. extern template int ImportedVarTmpl; // An explicit instantiation definition of an imported variable template cannot // be imported because the template must be defined which is illegal. // Import specialization of an imported variable template. template<> __declspec(dllimport) int ImportedVarTmpl; template<> __declspec(dllimport) int ImportedVarTmpl = 1; // expected-error{{definition of dllimport data}} // Not importing specialization of an imported variable template without // explicit dllimport. template<> int ImportedVarTmpl; // Import explicit instantiation declaration of a non-imported variable template. extern template __declspec(dllimport) int VarTmpl; // Import explicit instantiation definition of a non-imported variable template. template __declspec(dllimport) int VarTmpl; // Import specialization of a non-imported variable template. template<> __declspec(dllimport) int VarTmpl; template<> __declspec(dllimport) int VarTmpl = 1; // expected-error{{definition of dllimport data}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// d73 1 a73 1 __declspec(dllimport) void def() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} d76 1 a76 1 extern "C" __declspec(dllimport) void externC(); d79 2 a80 8 __declspec(dllimport) inline void inlineFunc1() {} inline void __attribute__((dllimport)) inlineFunc2() {} __declspec(dllimport) inline void inlineDecl(); void inlineDecl() {} __declspec(dllimport) void inlineDef(); inline void inlineDef() {} d86 1 a86 6 // NB: MSVC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) void redecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void redecl2(); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} a88 36 void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}} void redecl5(); // expected-note{{previous declaration is here}} __declspec(dllimport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllimport' attribute}} // Friend functions struct FuncFriend { friend __declspec(dllimport) void friend1(); friend __declspec(dllimport) void friend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend void friend4(); // expected-note{{previous declaration is here}} friend void friend5(); // expected-note{{previous declaration is here}} }; __declspec(dllimport) void friend1(); void friend2(); // expected-warning{{'friend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void friend3() {} // expected-warning{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void friend4(); // expected-error{{redeclaration of 'friend4' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void friend5() {} // expected-error{{redeclaration of 'friend5' cannot add 'dllimport' attribute}} // Implicit declarations can be redeclared with dllimport. __declspec(dllimport) void* operator new(__SIZE_TYPE__ n); // External linkage is required. __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal internalRetFunc(); // expected-error{{'internalRetFunc' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) void internalFunc(); } // expected-error{{'(anonymous namespace)::internalFunc' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) void externalFunc(); } // Import deleted functions. // FIXME: Deleted functions are definitions so a missing inline is diagnosed // here which is irrelevant. But because the delete keyword is parsed later // there is currently no straight-forward way to avoid this diagnostic. __declspec(dllimport) void deletedFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} a98 13 // Import function template definition. template __declspec(dllimport) void funcTmplDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // Import inline function template. template __declspec(dllimport) inline void inlineFuncTmpl1() {} template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} template __declspec(dllimport) inline void inlineFuncTmplDecl(); template void inlineFuncTmplDecl() {} template __declspec(dllimport) void inlineFuncTmplDef(); template inline void inlineFuncTmplDef() {} d103 2 a104 2 template __declspec(dllimport) void funcTmplRedecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template void funcTmplRedecl2(); // expected-warning{{'funcTmplRedecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} d106 1 a106 1 template __declspec(dllimport) void funcTmplRedecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} a108 26 template void funcTmplRedecl4(); // expected-note{{previous declaration is here}} template __declspec(dllimport) void funcTmplRedecl4(); // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllimport' attribute}} template void funcTmplRedecl5(); // expected-note{{previous declaration is here}} template __declspec(dllimport) inline void funcTmplRedecl5() {} // expected-error{{redeclaration of 'funcTmplRedecl5' cannot add 'dllimport' attribute}} // Function template friends struct FuncTmplFriend { template friend __declspec(dllimport) void funcTmplFriend1(); template friend __declspec(dllimport) void funcTmplFriend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend __declspec(dllimport) void funcTmplFriend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend void funcTmplFriend4(); // expected-note{{previous declaration is here}} template friend __declspec(dllimport) inline void funcTmplFriend5(); }; template __declspec(dllimport) void funcTmplFriend1(); template void funcTmplFriend2(); // expected-warning{{'funcTmplFriend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmplFriend3() {} // expected-warning{{'funcTmplFriend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) void funcTmplFriend4(); // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllimport' attribute}} template inline void funcTmplFriend5() {} // External linkage is required. template __declspec(dllimport) static int staticFuncTmpl(); // expected-error{{'staticFuncTmpl' must have external linkage when declared 'dllimport'}} template __declspec(dllimport) Internal internalRetFuncTmpl(); // expected-error{{'internalRetFuncTmpl' must have external linkage when declared 'dllimport'}} namespace { template __declspec(dllimport) void internalFuncTmpl(); } // expected-error{{'(anonymous namespace)::internalFuncTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template __declspec(dllimport) void externalFuncTmpl(); } d111 1 a111 15 template inline void inlineFuncTmpl() {} template __declspec(dllimport) void importedFuncTmplDecl(); template __declspec(dllimport) inline void importedFuncTmpl() {} // Import implicit instantiation of an imported function template. void useFunTmplDecl() { importedFuncTmplDecl(); } void useFunTmplDef() { importedFuncTmpl(); } // Import explicit instantiation declaration of an imported function template. extern template void importedFuncTmpl(); // Import explicit instantiation definition of an imported function template. // NB: MSVC fails this instantiation without explicit dllimport which is most // likely a bug because an implicit instantiation is accepted. template void importedFuncTmpl(); d116 2 a117 2 template<> __declspec(dllimport) void importedFuncTmpl() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} template<> __declspec(dllimport) inline void importedFuncTmpl() {} a125 5 extern template __declspec(dllimport) void inlineFuncTmpl(); // Import explicit instantiation definition of a non-imported function template. template __declspec(dllimport) void funcTmpl(); template __declspec(dllimport) void inlineFuncTmpl(); d130 2 a131 587 template<> __declspec(dllimport) void funcTmpl() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} template<> __declspec(dllimport) inline void funcTmpl() {} //===----------------------------------------------------------------------===// // Class members //===----------------------------------------------------------------------===// // Import individual members of a class. struct ImportMembers { struct Nested { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables and functions}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; void ImportMembers::Nested::normalDef() {} // expected-warning{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void ImportMembers::normalDef() {} // expected-warning{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::normalInlineDef() {} void ImportMembers::normalInlineDecl() {} void ImportMembers::virtualDef() {} // expected-warning{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::virtualInlineDef() {} void ImportMembers::virtualInlineDecl() {} void ImportMembers::staticDef() {} // expected-warning{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::staticInlineDef() {} void ImportMembers::staticInlineDecl() {} int ImportMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} const int ImportMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} constexpr int ImportMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} // Import on member definitions. struct ImportMemberDefs { __declspec(dllimport) void normalDef(); __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDef(); __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDef(); __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); __declspec(dllimport) static int StaticField; __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) constexpr static int ConstexprField = 1; }; __declspec(dllimport) void ImportMemberDefs::normalDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::normalInlineDef() {} __declspec(dllimport) void ImportMemberDefs::normalInlineDecl() {} __declspec(dllimport) void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::virtualInlineDef() {} __declspec(dllimport) void ImportMemberDefs::virtualInlineDecl() {} __declspec(dllimport) void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::staticInlineDef() {} __declspec(dllimport) void ImportMemberDefs::staticInlineDecl() {} __declspec(dllimport) int ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) const int ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} // Import special member functions. struct ImportSpecials { __declspec(dllimport) ImportSpecials(); __declspec(dllimport) ~ImportSpecials(); __declspec(dllimport) ImportSpecials(const ImportSpecials&); __declspec(dllimport) ImportSpecials& operator=(const ImportSpecials&); __declspec(dllimport) ImportSpecials(ImportSpecials&&); __declspec(dllimport) ImportSpecials& operator=(ImportSpecials&&); }; // Import deleted member functions. struct ImportDeleted { __declspec(dllimport) ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) void deleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} }; // Import allocation functions. struct ImportAlloc { __declspec(dllimport) void* operator new(__SIZE_TYPE__); __declspec(dllimport) void* operator new[](__SIZE_TYPE__); __declspec(dllimport) void operator delete(void*); __declspec(dllimport) void operator delete[](void*); }; // Import defaulted member functions. struct ImportDefaulted { __declspec(dllimport) ImportDefaulted() = default; __declspec(dllimport) ~ImportDefaulted() = default; __declspec(dllimport) ImportDefaulted(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted& operator=(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted(ImportDefaulted&&) = default; __declspec(dllimport) ImportDefaulted& operator=(ImportDefaulted&&) = default; }; // Import defaulted member function definitions. struct ImportDefaultedDefs { __declspec(dllimport) ImportDefaultedDefs(); __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) inline ImportDefaultedDefs(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs& operator=(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs(ImportDefaultedDefs&&); __declspec(dllimport) ImportDefaultedDefs& operator=(ImportDefaultedDefs&&); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; // Not allowed on definitions. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs() = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} // dllimport cannot be dropped. ImportDefaultedDefs::~ImportDefaultedDefs() = default; // expected-warning{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Import inline declaration and definition. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(const ImportDefaultedDefs&) = default; inline ImportDefaultedDefs& ImportDefaultedDefs::operator=(const ImportDefaultedDefs&) = default; __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(ImportDefaultedDefs&&) = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} ImportDefaultedDefs& ImportDefaultedDefs::operator=(ImportDefaultedDefs&&) = default; // expected-warning{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations cannot add dllimport. struct MemberRedecl { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual void virtualInlineDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; __declspec(dllimport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) int MemberRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} __declspec(dllimport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} __declspec(dllimport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class member templates //===----------------------------------------------------------------------===// struct ImportMemberTmpl { template __declspec(dllimport) void normalDecl(); template __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) void normalInlineDef(); template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticDecl(); template __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) static void staticInclass() {} template __declspec(dllimport) static void staticInlineDef(); template __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template __declspec(dllimport) static int StaticField; template __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstField; template __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template __declspec(dllimport) constexpr static int ConstexprField = 1; template __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template void ImportMemberTmpl::normalDef() {} // expected-warning{{'ImportMemberTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::normalInlineDef() {} template void ImportMemberTmpl::normalInlineDecl() {} template void ImportMemberTmpl::staticDef() {} // expected-warning{{'ImportMemberTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::staticInlineDef() {} template void ImportMemberTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template int ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template const int ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template constexpr int ImportMemberTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. struct MemTmplRedecl { template void normalDef(); // expected-note{{previous declaration is here}} template void normalInlineDef(); // expected-note{{previous declaration is here}} template inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template static void staticDef(); // expected-note{{previous declaration is here}} template static void staticInlineDef(); // expected-note{{previous declaration is here}} template static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #if __has_feature(cxx_variable_templates) template static int StaticField; // expected-note{{previous declaration is here}} template static const int StaticConstField; // expected-note{{previous declaration is here}} template constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template __declspec(dllimport) void MemTmplRedecl::normalDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::staticDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template __declspec(dllimport) int MemTmplRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) struct MemFunTmpl { template void normalDef() {} template __declspec(dllimport) void importedNormal() {} template static void staticDef() {} template __declspec(dllimport) static void importedStatic() {} }; // Import implicit instantiation of an imported member function template. void useMemFunTmpl() { MemFunTmpl().importedNormal(); MemFunTmpl().importedStatic(); } // Import explicit instantiation declaration of an imported member function // template. extern template void MemFunTmpl::importedNormal(); extern template void MemFunTmpl::importedStatic(); // Import explicit instantiation definition of an imported member function // template. // NB: MSVC fails this instantiation without explicit dllimport. template void MemFunTmpl::importedNormal(); template void MemFunTmpl::importedStatic(); // Import specialization of an imported member function template. template<> __declspec(dllimport) void MemFunTmpl::importedNormal(); template<> __declspec(dllimport) void MemFunTmpl::importedNormal() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::importedNormal() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::importedStatic(); template<> __declspec(dllimport) void MemFunTmpl::importedStatic() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::importedStatic() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif // Not importing specialization of an imported member function template without // explicit dllimport. template<> void MemFunTmpl::importedNormal() {} template<> void MemFunTmpl::importedStatic() {} // Import explicit instantiation declaration of a non-imported member function // template. extern template __declspec(dllimport) void MemFunTmpl::normalDef(); extern template __declspec(dllimport) void MemFunTmpl::staticDef(); // Import explicit instantiation definition of a non-imported member function // template. template __declspec(dllimport) void MemFunTmpl::normalDef(); template __declspec(dllimport) void MemFunTmpl::staticDef(); // Import specialization of a non-imported member function template. template<> __declspec(dllimport) void MemFunTmpl::normalDef(); template<> __declspec(dllimport) void MemFunTmpl::normalDef() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::normalDef() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::staticDef(); template<> __declspec(dllimport) void MemFunTmpl::staticDef() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::staticDef() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif #if __has_feature(cxx_variable_templates) struct MemVarTmpl { template static const int StaticVar = 1; template __declspec(dllimport) static const int ImportedStaticVar = 1; }; // Import implicit instantiation of an imported member variable template. int useMemVarTmpl() { return MemVarTmpl::ImportedStaticVar; } // Import explicit instantiation declaration of an imported member variable // template. extern template const int MemVarTmpl::ImportedStaticVar; // An explicit instantiation definition of an imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of an imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar; template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar = 1; // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} // Not importing specialization of a member variable template without explicit // dllimport. template<> const int MemVarTmpl::ImportedStaticVar; // Import explicit instantiation declaration of a non-imported member variable // template. extern template __declspec(dllimport) const int MemVarTmpl::StaticVar; // An explicit instantiation definition of a non-imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of a non-imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::StaticVar; template<> __declspec(dllimport) const int MemVarTmpl::StaticVar = 1; // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Class template members //===----------------------------------------------------------------------===// // Import individual members of a class template. template struct ImportClassTmplMembers { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables and functions}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; // NB: MSVC is inconsistent here and disallows *InlineDef on class templates, // but allows it on classes. We allow both. template void ImportClassTmplMembers::normalDef() {} // expected-warning{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::normalInlineDef() {} template void ImportClassTmplMembers::normalInlineDecl() {} template void ImportClassTmplMembers::virtualDef() {} // expected-warning{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::virtualInlineDef() {} template void ImportClassTmplMembers::virtualInlineDecl() {} template void ImportClassTmplMembers::staticDef() {} // expected-warning{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::staticInlineDef() {} template void ImportClassTmplMembers::staticInlineDecl() {} template int ImportClassTmplMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template const int ImportClassTmplMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template constexpr int ImportClassTmplMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} // Redeclarations cannot add dllimport. template struct CTMR /*ClassTmplMemberRedecl*/ { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual void virtualInlineDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; template __declspec(dllimport) void CTMR::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::virtualDef() {} // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::virtualInlineDecl() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::staticDef() {} // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) int CTMR::StaticField = 1; // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) const int CTMR::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) constexpr int CTMR::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class template member templates //===----------------------------------------------------------------------===// template struct ImportClsTmplMemTmpl { template __declspec(dllimport) void normalDecl(); template __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) void normalInlineDef(); template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticDecl(); template __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) static void staticInclass() {} template __declspec(dllimport) static void staticInlineDef(); template __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template __declspec(dllimport) static int StaticField; template __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstField; template __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template __declspec(dllimport) constexpr static int ConstexprField = 1; template __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template template void ImportClsTmplMemTmpl::normalDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} template template void ImportClsTmplMemTmpl::normalInlineDecl() {} template template void ImportClsTmplMemTmpl::staticDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} template template void ImportClsTmplMemTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template template int ImportClsTmplMemTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template template const int ImportClsTmplMemTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template template constexpr int ImportClsTmplMemTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. template struct CTMTR /*ClassTmplMemberTmplRedecl*/ { template void normalDef(); // expected-note{{previous declaration is here}} template void normalInlineDef(); // expected-note{{previous declaration is here}} template inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template static void staticDef(); // expected-note{{previous declaration is here}} template static void staticInlineDef(); // expected-note{{previous declaration is here}} template static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #if __has_feature(cxx_variable_templates) template static int StaticField; // expected-note{{previous declaration is here}} template static const int StaticConstField; // expected-note{{previous declaration is here}} template constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template template __declspec(dllimport) void CTMTR::normalDef() {} // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::staticDef() {} // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template template __declspec(dllimport) int CTMTR::StaticField = 1; // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template template __declspec(dllimport) const int CTMTR::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template template __declspec(dllimport) constexpr int CTMTR::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) @ 1.1.1.2 log @Import Clang 3.5svn r209886. @ text @a13 1 namespace { struct Internal {}; } a36 2 int **__attribute__((dllimport))* GlobalDeclChunkAttr; int GlobalDeclAttr __attribute__((dllimport)); d44 2 a45 11 __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int ExternGlobalDeclInit = 1; // expected-warning{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclInit = 1; // expected-warning{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int *GlobalDeclChunkAttrInit = 0; // expected-warning{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclAttrInit = 1; // expected-warning{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} a50 26 __declspec(dllimport) int GlobalRedecl2a; __declspec(dllimport) int GlobalRedecl2a; int *__attribute__((dllimport)) GlobalRedecl2b; int *__attribute__((dllimport)) GlobalRedecl2b; int GlobalRedecl2c __attribute__((dllimport)); int GlobalRedecl2c __attribute__((dllimport)); // NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} extern int GlobalRedecl4; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) int ExternalGlobal; } __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}} // expected-error@@-1{{definition of dllimport data}} a51 3 __declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}} a52 4 __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}} int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}} int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redefinition of 'LocalRedecl3' with a different type: 'int' vs 'float'}} a56 1 __declspec(dllimport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllimport'}} a61 80 // Variable templates //===----------------------------------------------------------------------===// #if __has_feature(cxx_variable_templates) // Import declaration. template __declspec(dllimport) extern int ExternVarTmplDecl; // dllimport implies a declaration. template __declspec(dllimport) int VarTmplDecl; // Not allowed on definitions. template __declspec(dllimport) extern int ExternVarTmplInit = 1; // expected-error{{definition of dllimport data}} template __declspec(dllimport) int VarTmplInit1 = 1; // expected-error{{definition of dllimport data}} template int __declspec(dllimport) VarTmplInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. template __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template int ExternVarTmplDeclInit = 1; // expected-warning{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) int VarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template int VarTmplDeclInit = 1; // expected-warning{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations template __declspec(dllimport) extern int VarTmplRedecl1; template __declspec(dllimport) extern int VarTmplRedecl1; template __declspec(dllimport) int VarTmplRedecl2; template __declspec(dllimport) int VarTmplRedecl2; template __declspec(dllimport) extern int VarTmplRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template extern int VarTmplRedecl3; // expected-warning{{'VarTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template extern int VarTmplRedecl4; // expected-note{{previous declaration is here}} template __declspec(dllimport) extern int VarTmplRedecl4; // expected-error{{redeclaration of 'VarTmplRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. template __declspec(dllimport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllimport'}} template __declspec(dllimport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllimport'}} namespace { template __declspec(dllimport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template __declspec(dllimport) int ExternalVarTmpl; } template __declspec(dllimport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{definition of dllimport data}} // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllimport'}} template int VarTmpl; template __declspec(dllimport) int ImportedVarTmpl; // Import implicit instantiation of an imported variable template. int useVarTmpl() { return ImportedVarTmpl; } // Import explicit instantiation declaration of an imported variable template. extern template int ImportedVarTmpl; // An explicit instantiation definition of an imported variable template cannot // be imported because the template must be defined which is illegal. // Import specialization of an imported variable template. template<> __declspec(dllimport) int ImportedVarTmpl; template<> __declspec(dllimport) int ImportedVarTmpl = 1; // expected-error{{definition of dllimport data}} // Not importing specialization of an imported variable template without // explicit dllimport. template<> int ImportedVarTmpl; // Import explicit instantiation declaration of a non-imported variable template. extern template __declspec(dllimport) int VarTmpl; // Import explicit instantiation definition of a non-imported variable template. template __declspec(dllimport) int VarTmpl; // Import specialization of a non-imported variable template. template<> __declspec(dllimport) int VarTmpl; template<> __declspec(dllimport) int VarTmpl = 1; // expected-error{{definition of dllimport data}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// d73 1 a73 1 __declspec(dllimport) void def() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} d76 1 a76 1 extern "C" __declspec(dllimport) void externC(); d79 2 a80 8 __declspec(dllimport) inline void inlineFunc1() {} inline void __attribute__((dllimport)) inlineFunc2() {} __declspec(dllimport) inline void inlineDecl(); void inlineDecl() {} __declspec(dllimport) void inlineDef(); inline void inlineDef() {} d86 1 a86 6 // NB: MSVC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) void redecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void redecl2(); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} a88 36 void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}} void redecl5(); // expected-note{{previous declaration is here}} __declspec(dllimport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllimport' attribute}} // Friend functions struct FuncFriend { friend __declspec(dllimport) void friend1(); friend __declspec(dllimport) void friend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend void friend4(); // expected-note{{previous declaration is here}} friend void friend5(); // expected-note{{previous declaration is here}} }; __declspec(dllimport) void friend1(); void friend2(); // expected-warning{{'friend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void friend3() {} // expected-warning{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void friend4(); // expected-error{{redeclaration of 'friend4' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void friend5() {} // expected-error{{redeclaration of 'friend5' cannot add 'dllimport' attribute}} // Implicit declarations can be redeclared with dllimport. __declspec(dllimport) void* operator new(__SIZE_TYPE__ n); // External linkage is required. __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal internalRetFunc(); // expected-error{{'internalRetFunc' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) void internalFunc(); } // expected-error{{'(anonymous namespace)::internalFunc' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) void externalFunc(); } // Import deleted functions. // FIXME: Deleted functions are definitions so a missing inline is diagnosed // here which is irrelevant. But because the delete keyword is parsed later // there is currently no straight-forward way to avoid this diagnostic. __declspec(dllimport) void deletedFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} a98 13 // Import function template definition. template __declspec(dllimport) void funcTmplDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // Import inline function template. template __declspec(dllimport) inline void inlineFuncTmpl1() {} template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} template __declspec(dllimport) inline void inlineFuncTmplDecl(); template void inlineFuncTmplDecl() {} template __declspec(dllimport) void inlineFuncTmplDef(); template inline void inlineFuncTmplDef() {} d103 2 a104 2 template __declspec(dllimport) void funcTmplRedecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template void funcTmplRedecl2(); // expected-warning{{'funcTmplRedecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} d106 1 a106 1 template __declspec(dllimport) void funcTmplRedecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} a108 26 template void funcTmplRedecl4(); // expected-note{{previous declaration is here}} template __declspec(dllimport) void funcTmplRedecl4(); // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllimport' attribute}} template void funcTmplRedecl5(); // expected-note{{previous declaration is here}} template __declspec(dllimport) inline void funcTmplRedecl5() {} // expected-error{{redeclaration of 'funcTmplRedecl5' cannot add 'dllimport' attribute}} // Function template friends struct FuncTmplFriend { template friend __declspec(dllimport) void funcTmplFriend1(); template friend __declspec(dllimport) void funcTmplFriend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend __declspec(dllimport) void funcTmplFriend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend void funcTmplFriend4(); // expected-note{{previous declaration is here}} template friend __declspec(dllimport) inline void funcTmplFriend5(); }; template __declspec(dllimport) void funcTmplFriend1(); template void funcTmplFriend2(); // expected-warning{{'funcTmplFriend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmplFriend3() {} // expected-warning{{'funcTmplFriend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) void funcTmplFriend4(); // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllimport' attribute}} template inline void funcTmplFriend5() {} // External linkage is required. template __declspec(dllimport) static int staticFuncTmpl(); // expected-error{{'staticFuncTmpl' must have external linkage when declared 'dllimport'}} template __declspec(dllimport) Internal internalRetFuncTmpl(); // expected-error{{'internalRetFuncTmpl' must have external linkage when declared 'dllimport'}} namespace { template __declspec(dllimport) void internalFuncTmpl(); } // expected-error{{'(anonymous namespace)::internalFuncTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template __declspec(dllimport) void externalFuncTmpl(); } d111 1 a111 15 template inline void inlineFuncTmpl() {} template __declspec(dllimport) void importedFuncTmplDecl(); template __declspec(dllimport) inline void importedFuncTmpl() {} // Import implicit instantiation of an imported function template. void useFunTmplDecl() { importedFuncTmplDecl(); } void useFunTmplDef() { importedFuncTmpl(); } // Import explicit instantiation declaration of an imported function template. extern template void importedFuncTmpl(); // Import explicit instantiation definition of an imported function template. // NB: MSVC fails this instantiation without explicit dllimport which is most // likely a bug because an implicit instantiation is accepted. template void importedFuncTmpl(); d116 2 a117 2 template<> __declspec(dllimport) void importedFuncTmpl() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} template<> __declspec(dllimport) inline void importedFuncTmpl() {} a125 5 extern template __declspec(dllimport) void inlineFuncTmpl(); // Import explicit instantiation definition of a non-imported function template. template __declspec(dllimport) void funcTmpl(); template __declspec(dllimport) void inlineFuncTmpl(); d130 2 a131 587 template<> __declspec(dllimport) void funcTmpl() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} template<> __declspec(dllimport) inline void funcTmpl() {} //===----------------------------------------------------------------------===// // Class members //===----------------------------------------------------------------------===// // Import individual members of a class. struct ImportMembers { struct Nested { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables and functions}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; void ImportMembers::Nested::normalDef() {} // expected-warning{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void ImportMembers::normalDef() {} // expected-warning{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::normalInlineDef() {} void ImportMembers::normalInlineDecl() {} void ImportMembers::virtualDef() {} // expected-warning{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::virtualInlineDef() {} void ImportMembers::virtualInlineDecl() {} void ImportMembers::staticDef() {} // expected-warning{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::staticInlineDef() {} void ImportMembers::staticInlineDecl() {} int ImportMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} const int ImportMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} constexpr int ImportMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} // Import on member definitions. struct ImportMemberDefs { __declspec(dllimport) void normalDef(); __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDef(); __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDef(); __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); __declspec(dllimport) static int StaticField; __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) constexpr static int ConstexprField = 1; }; __declspec(dllimport) void ImportMemberDefs::normalDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::normalInlineDef() {} __declspec(dllimport) void ImportMemberDefs::normalInlineDecl() {} __declspec(dllimport) void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::virtualInlineDef() {} __declspec(dllimport) void ImportMemberDefs::virtualInlineDecl() {} __declspec(dllimport) void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::staticInlineDef() {} __declspec(dllimport) void ImportMemberDefs::staticInlineDecl() {} __declspec(dllimport) int ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) const int ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} // Import special member functions. struct ImportSpecials { __declspec(dllimport) ImportSpecials(); __declspec(dllimport) ~ImportSpecials(); __declspec(dllimport) ImportSpecials(const ImportSpecials&); __declspec(dllimport) ImportSpecials& operator=(const ImportSpecials&); __declspec(dllimport) ImportSpecials(ImportSpecials&&); __declspec(dllimport) ImportSpecials& operator=(ImportSpecials&&); }; // Import deleted member functions. struct ImportDeleted { __declspec(dllimport) ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) void deleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} }; // Import allocation functions. struct ImportAlloc { __declspec(dllimport) void* operator new(__SIZE_TYPE__); __declspec(dllimport) void* operator new[](__SIZE_TYPE__); __declspec(dllimport) void operator delete(void*); __declspec(dllimport) void operator delete[](void*); }; // Import defaulted member functions. struct ImportDefaulted { __declspec(dllimport) ImportDefaulted() = default; __declspec(dllimport) ~ImportDefaulted() = default; __declspec(dllimport) ImportDefaulted(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted& operator=(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted(ImportDefaulted&&) = default; __declspec(dllimport) ImportDefaulted& operator=(ImportDefaulted&&) = default; }; // Import defaulted member function definitions. struct ImportDefaultedDefs { __declspec(dllimport) ImportDefaultedDefs(); __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) inline ImportDefaultedDefs(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs& operator=(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs(ImportDefaultedDefs&&); __declspec(dllimport) ImportDefaultedDefs& operator=(ImportDefaultedDefs&&); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; // Not allowed on definitions. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs() = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} // dllimport cannot be dropped. ImportDefaultedDefs::~ImportDefaultedDefs() = default; // expected-warning{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Import inline declaration and definition. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(const ImportDefaultedDefs&) = default; inline ImportDefaultedDefs& ImportDefaultedDefs::operator=(const ImportDefaultedDefs&) = default; __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(ImportDefaultedDefs&&) = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} ImportDefaultedDefs& ImportDefaultedDefs::operator=(ImportDefaultedDefs&&) = default; // expected-warning{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations cannot add dllimport. struct MemberRedecl { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual void virtualInlineDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; __declspec(dllimport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) int MemberRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} __declspec(dllimport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} __declspec(dllimport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class member templates //===----------------------------------------------------------------------===// struct ImportMemberTmpl { template __declspec(dllimport) void normalDecl(); template __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) void normalInlineDef(); template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticDecl(); template __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) static void staticInclass() {} template __declspec(dllimport) static void staticInlineDef(); template __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template __declspec(dllimport) static int StaticField; template __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstField; template __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template __declspec(dllimport) constexpr static int ConstexprField = 1; template __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template void ImportMemberTmpl::normalDef() {} // expected-warning{{'ImportMemberTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::normalInlineDef() {} template void ImportMemberTmpl::normalInlineDecl() {} template void ImportMemberTmpl::staticDef() {} // expected-warning{{'ImportMemberTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::staticInlineDef() {} template void ImportMemberTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template int ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template const int ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template constexpr int ImportMemberTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. struct MemTmplRedecl { template void normalDef(); // expected-note{{previous declaration is here}} template void normalInlineDef(); // expected-note{{previous declaration is here}} template inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template static void staticDef(); // expected-note{{previous declaration is here}} template static void staticInlineDef(); // expected-note{{previous declaration is here}} template static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #if __has_feature(cxx_variable_templates) template static int StaticField; // expected-note{{previous declaration is here}} template static const int StaticConstField; // expected-note{{previous declaration is here}} template constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template __declspec(dllimport) void MemTmplRedecl::normalDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::staticDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template __declspec(dllimport) int MemTmplRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) struct MemFunTmpl { template void normalDef() {} template __declspec(dllimport) void importedNormal() {} template static void staticDef() {} template __declspec(dllimport) static void importedStatic() {} }; // Import implicit instantiation of an imported member function template. void useMemFunTmpl() { MemFunTmpl().importedNormal(); MemFunTmpl().importedStatic(); } // Import explicit instantiation declaration of an imported member function // template. extern template void MemFunTmpl::importedNormal(); extern template void MemFunTmpl::importedStatic(); // Import explicit instantiation definition of an imported member function // template. // NB: MSVC fails this instantiation without explicit dllimport. template void MemFunTmpl::importedNormal(); template void MemFunTmpl::importedStatic(); // Import specialization of an imported member function template. template<> __declspec(dllimport) void MemFunTmpl::importedNormal(); template<> __declspec(dllimport) void MemFunTmpl::importedNormal() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::importedNormal() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::importedStatic(); template<> __declspec(dllimport) void MemFunTmpl::importedStatic() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::importedStatic() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif // Not importing specialization of an imported member function template without // explicit dllimport. template<> void MemFunTmpl::importedNormal() {} template<> void MemFunTmpl::importedStatic() {} // Import explicit instantiation declaration of a non-imported member function // template. extern template __declspec(dllimport) void MemFunTmpl::normalDef(); extern template __declspec(dllimport) void MemFunTmpl::staticDef(); // Import explicit instantiation definition of a non-imported member function // template. template __declspec(dllimport) void MemFunTmpl::normalDef(); template __declspec(dllimport) void MemFunTmpl::staticDef(); // Import specialization of a non-imported member function template. template<> __declspec(dllimport) void MemFunTmpl::normalDef(); template<> __declspec(dllimport) void MemFunTmpl::normalDef() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::normalDef() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::staticDef(); template<> __declspec(dllimport) void MemFunTmpl::staticDef() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::staticDef() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif #if __has_feature(cxx_variable_templates) struct MemVarTmpl { template static const int StaticVar = 1; template __declspec(dllimport) static const int ImportedStaticVar = 1; }; // Import implicit instantiation of an imported member variable template. int useMemVarTmpl() { return MemVarTmpl::ImportedStaticVar; } // Import explicit instantiation declaration of an imported member variable // template. extern template const int MemVarTmpl::ImportedStaticVar; // An explicit instantiation definition of an imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of an imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar; template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar = 1; // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} // Not importing specialization of a member variable template without explicit // dllimport. template<> const int MemVarTmpl::ImportedStaticVar; // Import explicit instantiation declaration of a non-imported member variable // template. extern template __declspec(dllimport) const int MemVarTmpl::StaticVar; // An explicit instantiation definition of a non-imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of a non-imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::StaticVar; template<> __declspec(dllimport) const int MemVarTmpl::StaticVar = 1; // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Class template members //===----------------------------------------------------------------------===// // Import individual members of a class template. template struct ImportClassTmplMembers { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables and functions}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; // NB: MSVC is inconsistent here and disallows *InlineDef on class templates, // but allows it on classes. We allow both. template void ImportClassTmplMembers::normalDef() {} // expected-warning{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::normalInlineDef() {} template void ImportClassTmplMembers::normalInlineDecl() {} template void ImportClassTmplMembers::virtualDef() {} // expected-warning{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::virtualInlineDef() {} template void ImportClassTmplMembers::virtualInlineDecl() {} template void ImportClassTmplMembers::staticDef() {} // expected-warning{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::staticInlineDef() {} template void ImportClassTmplMembers::staticInlineDecl() {} template int ImportClassTmplMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template const int ImportClassTmplMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template constexpr int ImportClassTmplMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} // Redeclarations cannot add dllimport. template struct CTMR /*ClassTmplMemberRedecl*/ { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual void virtualInlineDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; template __declspec(dllimport) void CTMR::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::virtualDef() {} // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::virtualInlineDecl() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::staticDef() {} // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) int CTMR::StaticField = 1; // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) const int CTMR::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) constexpr int CTMR::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class template member templates //===----------------------------------------------------------------------===// template struct ImportClsTmplMemTmpl { template __declspec(dllimport) void normalDecl(); template __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) void normalInlineDef(); template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticDecl(); template __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) static void staticInclass() {} template __declspec(dllimport) static void staticInlineDef(); template __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template __declspec(dllimport) static int StaticField; template __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstField; template __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template __declspec(dllimport) constexpr static int ConstexprField = 1; template __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template template void ImportClsTmplMemTmpl::normalDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} template template void ImportClsTmplMemTmpl::normalInlineDecl() {} template template void ImportClsTmplMemTmpl::staticDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} template template void ImportClsTmplMemTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template template int ImportClsTmplMemTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template template const int ImportClsTmplMemTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template template constexpr int ImportClsTmplMemTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. template struct CTMTR /*ClassTmplMemberTmplRedecl*/ { template void normalDef(); // expected-note{{previous declaration is here}} template void normalInlineDef(); // expected-note{{previous declaration is here}} template inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template static void staticDef(); // expected-note{{previous declaration is here}} template static void staticInlineDef(); // expected-note{{previous declaration is here}} template static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #if __has_feature(cxx_variable_templates) template static int StaticField; // expected-note{{previous declaration is here}} template static const int StaticConstField; // expected-note{{previous declaration is here}} template constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template template __declspec(dllimport) void CTMTR::normalDef() {} // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::staticDef() {} // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template template __declspec(dllimport) int CTMTR::StaticField = 1; // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template template __declspec(dllimport) const int CTMTR::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template template __declspec(dllimport) constexpr int CTMTR::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) @ 1.1.1.3 log @Import clang 3.6svn r215315. @ text @d1 2 a2 2 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c++11 -DMS %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c++1y -DMS %s d18 5 a22 5 __declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) int typedef2; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef int __declspec(dllimport) typedef3; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} enum __declspec(dllimport) Enum {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} d24 1 a24 1 enum class __declspec(dllimport) EnumClass {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} a245 7 void __declspec(dllimport) friend6(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void __declspec(dllimport) friend7(); struct FuncFriend2 { friend void friend6(); // expected-warning{{'friend6' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} friend void ::friend7(); }; d365 1 d399 1 a399 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} d797 1 a797 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} d820 3 a822 3 template int ImportClassTmplMembers::StaticFieldDef; // expected-warning{{definition of dllimport static field}} template const int ImportClassTmplMembers::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}} template constexpr int ImportClassTmplMembers::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}} d857 1 a857 1 // expected-warning@@-1{{definition of dllimport static field}} d860 1 a860 1 // expected-warning@@-1{{definition of dllimport static field}} d863 1 a863 1 // expected-warning@@-1{{definition of dllimport static field}} d905 3 a907 3 template template int ImportClsTmplMemTmpl::StaticFieldDef; // expected-warning{{definition of dllimport static field}} template template const int ImportClsTmplMemTmpl::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}} template template constexpr int ImportClsTmplMemTmpl::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}} d939 1 a939 1 // expected-warning@@-1{{definition of dllimport static field}} d942 1 a942 1 // expected-warning@@-1{{definition of dllimport static field}} d945 1 a945 1 // expected-warning@@-1{{definition of dllimport static field}} a947 139 //===----------------------------------------------------------------------===// // Classes //===----------------------------------------------------------------------===// class __declspec(dllimport) ClassDecl; class __declspec(dllimport) ClassDef { }; template class ClassTemplate {}; #ifdef MS // expected-note@@+5{{previous attribute is here}} // expected-note@@+4{{previous attribute is here}} // expected-error@@+4{{attribute 'dllexport' cannot be applied to member of 'dllimport' class}} // expected-error@@+4{{attribute 'dllimport' cannot be applied to member of 'dllimport' class}} #endif class __declspec(dllimport) ImportClassWithDllMember { void __declspec(dllexport) foo(); void __declspec(dllimport) bar(); }; #ifdef MS // expected-note@@+5{{previous attribute is here}} // expected-note@@+4{{previous attribute is here}} // expected-error@@+4{{attribute 'dllimport' cannot be applied to member of 'dllexport' class}} // expected-error@@+4{{attribute 'dllexport' cannot be applied to member of 'dllexport' class}} #endif class __declspec(dllexport) ExportClassWithDllMember { void __declspec(dllimport) foo(); void __declspec(dllexport) bar(); }; namespace ImportedExplicitSpecialization { template struct S { static int x; }; template int S::x = sizeof(T); template <> struct __declspec(dllimport) S { static int x; }; // expected-note{{attribute is here}} int S::x = -1; // expected-error{{definition of dllimport static field not allowed}} } namespace PR19988 { // Don't error about applying delete to dllimport member function when instantiating. template struct __declspec(dllimport) S { void foo() = delete; }; S s; } #ifdef MS // expected-warning@@+3{{'dllimport' attribute ignored}} #endif template struct PartiallySpecializedClassTemplate {}; template struct __declspec(dllimport) PartiallySpecializedClassTemplate { void f() {} }; template struct ExpliciallySpecializedClassTemplate {}; template <> struct __declspec(dllimport) ExpliciallySpecializedClassTemplate { void f() {} }; //===----------------------------------------------------------------------===// // Classes with template base classes //===----------------------------------------------------------------------===// template class __declspec(dllexport) ExportedClassTemplate {}; template class __declspec(dllimport) ImportedClassTemplate {}; // ClassTemplate gets imported. class __declspec(dllimport) DerivedFromTemplate : public ClassTemplate {}; // ClassTemplate is already imported. class __declspec(dllimport) DerivedFromTemplate2 : public ClassTemplate {}; // ImportedClassTemplate is expliitly imported. class __declspec(dllimport) DerivedFromImportedTemplate : public ImportedClassTemplate {}; // ExportedClassTemplate is explicitly exported. class __declspec(dllimport) DerivedFromExportedTemplate : public ExportedClassTemplate {}; #ifdef MS // expected-note@@+4{{class template 'ClassTemplate' was instantiated here}} // expected-warning@@+4{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}} // expected-note@@+3{{attribute is here}} #endif class DerivedFromTemplateD : public ClassTemplate {}; class __declspec(dllimport) DerivedFromTemplateD2 : public ClassTemplate {}; #ifdef MS // expected-note@@+4{{class template 'ClassTemplate' was instantiated here}} // expected-warning@@+4{{propagating dll attribute to already instantiated base class template with different dll attribute is not supported}} // expected-note@@+3{{attribute is here}} #endif class __declspec(dllexport) DerivedFromTemplateB : public ClassTemplate {}; class __declspec(dllimport) DerivedFromTemplateB2 : public ClassTemplate {}; template struct ExplicitlySpecializedTemplate { void func() {} }; #ifdef MS // expected-note@@+2{{class template 'ExplicitlySpecializedTemplate' was explicitly specialized here}} #endif template <> struct ExplicitlySpecializedTemplate { void func() {} }; template struct ExplicitlyExportSpecializedTemplate { void func() {} }; template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate { void func() {} }; template struct ExplicitlyImportSpecializedTemplate { void func() {} }; template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate { void func() {} }; template struct ExplicitlyInstantiatedTemplate { void func() {} }; #ifdef MS // expected-note@@+2{{class template 'ExplicitlyInstantiatedTemplate' was instantiated here}} #endif template struct ExplicitlyInstantiatedTemplate; template struct ExplicitlyExportInstantiatedTemplate { void func() {} }; template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate; template struct ExplicitlyImportInstantiatedTemplate { void func() {} }; template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate; #ifdef MS // expected-warning@@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}} // expected-note@@+2{{attribute is here}} #endif struct __declspec(dllimport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate {}; // Base class already specialized with export attribute. struct __declspec(dllimport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate {}; // Base class already specialized with import attribute. struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate {}; #ifdef MS // expected-warning@@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}} // expected-note@@+2{{attribute is here}} #endif struct __declspec(dllimport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate {}; // Base class already instantiated with export attribute. struct __declspec(dllimport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate {}; // Base class already instantiated with import attribute. struct __declspec(dllimport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate {}; @ 1.1.1.3.2.1 log @Update LLVM to 3.6.1, requested by joerg in ticket 824. @ text @d1 4 a4 4 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s d78 1 a78 6 __declspec(dllimport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllimport' attribute}} extern "C" { extern int GlobalRedecl5; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclaration of 'GlobalRedecl5' should not add 'dllimport' attribute}} } a88 3 // Thread local variables are invalid. __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}} d186 1 a204 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} #endif a207 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a211 3 #ifdef GNU // expected-warning@@+2{{'inlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif d227 1 a227 1 __declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}} a228 1 extern "C" { d230 1 a230 10 __declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}} } #ifdef MS void redecl6(); // expected-note{{previous declaration is here}} __declspec(dllimport) inline void redecl6() {} // expected-warning{{redeclaration of 'redecl6' should not add 'dllimport' attribute}} #else void redecl6(); __declspec(dllimport) inline void redecl6() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif d238 1 a238 4 #ifdef MS // expected-note@@+2{{previous declaration is here}} #endif friend void friend5(); d243 2 a244 7 __declspec(dllimport) void friend4(); // expected-warning{{redeclaration of 'friend4' should not add 'dllimport' attribute}} #ifdef MS __declspec(dllimport) inline void friend5() {} // expected-warning{{redeclaration of 'friend5' should not add 'dllimport' attribute}} #else __declspec(dllimport) inline void friend5() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a266 1 #ifdef MS a267 3 #else __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a282 6 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} // expected-warning@@+9{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}} #endif a304 1 #ifdef MS a306 1 #endif a313 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a331 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a349 1 #ifdef MS a350 1 #endif a358 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a362 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a368 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a382 4 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} #endif a387 4 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} #endif a392 4 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} #endif a417 3 #ifdef GNU // expected-warning@@+2{{'ImportMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a420 3 #ifdef GNU // expected-warning@@+2{{'ImportMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a423 3 #ifdef GNU // expected-warning@@+2{{'ImportMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif d436 1 d439 1 a441 3 #ifdef MS __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual inline void virtualInlineDecl(); a442 1 #endif a449 3 __declspec(dllimport) void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} #ifdef MS d452 1 d455 1 a457 1 #endif a476 1 #ifdef MS a483 9 #else __declspec(dllimport) ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) void deleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a497 8 #ifdef GNU // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} #endif a511 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-note@@+2{{previous declaration is here}} #endif a525 4 #ifdef GNU // expected-error@@+3{{redeclaration of 'ImportDefaultedDefs::ImportDefaultedDefs' cannot add 'dllimport' attribute}} // expected-warning@@+3{{'ImportDefaultedDefs::operator=' redeclared inline; 'dllimport' attribute ignored}} #endif d536 1 d539 1 d542 1 a544 9 #ifdef MS // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} #endif void normalInlineDef(); virtual void virtualInlineDef(); static void staticInlineDef(); d552 1 d556 1 d560 1 a562 12 #ifdef MS __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}} #else __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif d582 1 d584 1 d587 1 a588 10 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} #endif template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticInclass() {} d604 1 d607 1 a609 7 #ifdef GNU // expected-warning@@+3{{ImportMemberTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} // expected-warning@@+3{{ImportMemberTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template inline void ImportMemberTmpl::normalInlineDef() {} template inline void ImportMemberTmpl::staticInlineDef() {} d620 1 d623 1 a625 7 #ifdef MS // expected-note@@+3{{previous declaration is here}} // expected-note@@+3{{previous declaration is here}} #endif template void normalInlineDef(); template static void staticInlineDef(); a634 1 #ifdef MS a635 3 #else template __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a638 1 #ifdef MS a639 3 #else template __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a657 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a659 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a682 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d684 2 a685 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} a689 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d691 2 a692 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} a702 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} #endif a707 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} #endif a713 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d715 2 a716 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} a720 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d722 2 a723 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} d783 1 d785 1 d788 1 d790 1 d793 1 a794 14 #ifdef GNU // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) void normalInclass() {} __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticInclass() {} a816 3 #ifdef GNU // expected-warning@@+2{{'ImportClassTmplMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a819 3 #ifdef GNU // expected-warning@@+2{{'ImportClassTmplMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a822 3 #ifdef GNU // expected-warning@@+2{{'ImportClassTmplMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif d835 1 d838 1 d841 1 a843 9 #ifdef MS // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} #endif void normalInlineDef(); virtual void virtualInlineDef(); static void staticInlineDef(); d851 1 d855 1 d859 1 a861 10 #ifdef MS template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}} #else template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif d882 1 d884 1 d887 1 a888 10 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} #endif template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticInclass() {} d904 1 d907 1 a909 7 #ifdef GNU // expected-warning@@+3{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} // expected-warning@@+3{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} d921 1 d924 1 a926 7 #ifdef MS // expected-note@@+3{{previous declaration is here}} // expected-note@@+3{{previous declaration is here}} #endif template void normalInlineDef(); template static void staticInlineDef(); d936 1 d940 1 a942 8 #ifdef MS template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}} #else template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a960 4 namespace { struct __declspec(dllimport) AnonymousClass {}; // expected-error{{(anonymous namespace)::AnonymousClass' must have external linkage when declared 'dllimport'}} } d984 1 a984 1 template class __declspec(dllexport) ExportClassWithDllMember { @ 1.1.1.4 log @Import Clang 3.6RC1 r227398. @ text @d1 4 a4 4 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s d78 1 a78 6 __declspec(dllimport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllimport' attribute}} extern "C" { extern int GlobalRedecl5; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclaration of 'GlobalRedecl5' should not add 'dllimport' attribute}} } a88 3 // Thread local variables are invalid. __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}} d186 1 a204 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} #endif a207 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a211 3 #ifdef GNU // expected-warning@@+2{{'inlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif d227 1 a227 1 __declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}} a228 1 extern "C" { d230 1 a230 10 __declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}} } #ifdef MS void redecl6(); // expected-note{{previous declaration is here}} __declspec(dllimport) inline void redecl6() {} // expected-warning{{redeclaration of 'redecl6' should not add 'dllimport' attribute}} #else void redecl6(); __declspec(dllimport) inline void redecl6() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif d238 1 a238 4 #ifdef MS // expected-note@@+2{{previous declaration is here}} #endif friend void friend5(); d243 2 a244 7 __declspec(dllimport) void friend4(); // expected-warning{{redeclaration of 'friend4' should not add 'dllimport' attribute}} #ifdef MS __declspec(dllimport) inline void friend5() {} // expected-warning{{redeclaration of 'friend5' should not add 'dllimport' attribute}} #else __declspec(dllimport) inline void friend5() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a266 1 #ifdef MS a267 3 #else __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a282 6 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} // expected-warning@@+9{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}} #endif a304 1 #ifdef MS a306 1 #endif a313 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a331 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a349 1 #ifdef MS a350 1 #endif a358 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a362 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a368 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a382 4 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} #endif a387 4 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} #endif a392 4 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+6{{'dllimport' attribute ignored on inline function}} #endif a417 3 #ifdef GNU // expected-warning@@+2{{'ImportMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a420 3 #ifdef GNU // expected-warning@@+2{{'ImportMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a423 3 #ifdef GNU // expected-warning@@+2{{'ImportMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif d436 1 d439 1 a441 3 #ifdef MS __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual inline void virtualInlineDecl(); a442 1 #endif a449 3 __declspec(dllimport) void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} #ifdef MS d452 1 d455 1 a457 1 #endif a476 1 #ifdef MS a483 9 #else __declspec(dllimport) ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) void deleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a497 8 #ifdef GNU // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} #endif a511 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-note@@+2{{previous declaration is here}} #endif a525 4 #ifdef GNU // expected-error@@+3{{redeclaration of 'ImportDefaultedDefs::ImportDefaultedDefs' cannot add 'dllimport' attribute}} // expected-warning@@+3{{'ImportDefaultedDefs::operator=' redeclared inline; 'dllimport' attribute ignored}} #endif d536 1 d539 1 d542 1 a544 9 #ifdef MS // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} #endif void normalInlineDef(); virtual void virtualInlineDef(); static void staticInlineDef(); d552 1 d556 1 d560 1 a562 12 #ifdef MS __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}} #else __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif d582 1 d584 1 d587 1 a588 10 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} #endif template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticInclass() {} d604 1 d607 1 a609 7 #ifdef GNU // expected-warning@@+3{{ImportMemberTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} // expected-warning@@+3{{ImportMemberTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template inline void ImportMemberTmpl::normalInlineDef() {} template inline void ImportMemberTmpl::staticInlineDef() {} d620 1 d623 1 a625 7 #ifdef MS // expected-note@@+3{{previous declaration is here}} // expected-note@@+3{{previous declaration is here}} #endif template void normalInlineDef(); template static void staticInlineDef(); a634 1 #ifdef MS a635 3 #else template __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a638 1 #ifdef MS a639 3 #else template __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a657 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a659 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif a682 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d684 2 a685 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} a689 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d691 2 a692 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} a702 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} #endif a707 4 #ifdef GNU // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@@+3{{'dllimport' attribute ignored on inline function}} #endif a713 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d715 2 a716 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} a720 3 #ifdef GNU // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif d722 2 a723 3 #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@@-7{{dllimport cannot be applied to non-inline function definition}} d783 1 d785 1 d788 1 d790 1 d793 1 a794 14 #ifdef GNU // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@@+7{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) void normalInclass() {} __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticInclass() {} a816 3 #ifdef GNU // expected-warning@@+2{{'ImportClassTmplMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a819 3 #ifdef GNU // expected-warning@@+2{{'ImportClassTmplMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif a822 3 #ifdef GNU // expected-warning@@+2{{'ImportClassTmplMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif d835 1 d838 1 d841 1 a843 9 #ifdef MS // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} // expected-note@@+4{{previous declaration is here}} #endif void normalInlineDef(); virtual void virtualInlineDef(); static void staticInlineDef(); d851 1 d855 1 d859 1 a861 10 #ifdef MS template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}} #else template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif d882 1 d884 1 d887 1 a888 10 #ifdef GNU // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@@+5{{'dllimport' attribute ignored on inline function}} #endif template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticInclass() {} d904 1 d907 1 a909 7 #ifdef GNU // expected-warning@@+3{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} // expected-warning@@+3{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} d921 1 d924 1 a926 7 #ifdef MS // expected-note@@+3{{previous declaration is here}} // expected-note@@+3{{previous declaration is here}} #endif template void normalInlineDef(); template static void staticInlineDef(); d936 1 d940 1 a942 8 #ifdef MS template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}} #else template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif a960 4 namespace { struct __declspec(dllimport) AnonymousClass {}; // expected-error{{(anonymous namespace)::AnonymousClass' must have external linkage when declared 'dllimport'}} } d984 1 a984 1 template class __declspec(dllexport) ExportClassWithDllMember { @ 1.1.1.5 log @Import Clang 3.8.0rc3 r261930. @ text @d1 4 a4 4 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s a95 6 // This doesn't work on MinGW, because there, dllimport on the inline function is ignored. #ifndef GNU inline void __declspec(dllimport) ImportedInlineWithThreadLocal() { static __thread int OK; // no-error } #endif d98 3 a100 3 __declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}} __declspec(dllimport) float LocalRedecl2; // expected-note{{previous declaration is here}} __declspec(dllimport) float LocalRedecl3; // expected-note{{previous declaration is here}} d102 3 a104 3 __declspec(dllimport) int LocalRedecl1; // expected-error{{redeclaration of 'LocalRedecl1' with a different type: 'int' vs 'float'}} int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redeclaration of 'LocalRedecl2' with a different type: 'int *' vs 'float'}} int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redeclaration of 'LocalRedecl3' with a different type: 'int' vs 'float'}} d1277 5 a1282 1 // Base class previously implicitly instantiated without attribute; it will get propagated. d1285 7 a1291 7 // Base class has explicit instantiation declaration; the attribute will get propagated. extern template class ClassTemplate; class __declspec(dllimport) DerivedFromTemplateF : public ClassTemplate {}; class __declspec(dllimport) DerivedFromTemplateB : public ClassTemplate {}; // The second derived class doesn't change anything, the attribute that was propagated first wins. class __declspec(dllexport) DerivedFromTemplateB2 : public ClassTemplate {}; a1335 15 template struct ExplicitInstantiationDeclTemplateBase { void func() {} }; extern template struct ExplicitInstantiationDeclTemplateBase; struct __declspec(dllimport) DerivedFromExplicitInstantiationDeclTemplateBase : public ExplicitInstantiationDeclTemplateBase {}; //===----------------------------------------------------------------------===// // Lambdas //===----------------------------------------------------------------------===// // The MS ABI doesn't provide a stable mangling for lambdas, so they can't be imported or exported. #ifdef MS // expected-error@@+4{{lambda cannot be declared 'dllimport'}} #else // expected-warning@@+2{{'dllimport' attribute ignored on inline function}} #endif auto Lambda = []() __declspec(dllimport) -> bool { return true; }; @ 1.1.1.5.2.1 log @Sync with HEAD @ text @d18 5 a22 10 __declspec(dllimport) typedef int typedef1; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) int typedef2; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} typedef int __declspec(dllimport) typedef3; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} enum __declspec(dllimport) Enum {}; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} d24 1 a24 2 enum class __declspec(dllimport) EnumClass {}; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} d47 2 a48 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int ExternGlobalDeclInit = 1; d50 2 a51 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'GlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int GlobalDeclInit = 1; d53 2 a54 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int *GlobalDeclChunkAttrInit = 0; d56 2 a57 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int GlobalDeclAttrInit = 1; d72 2 d138 2 a139 12 #ifdef GNU // expected-note@@+3{{previous attribute is here}} #endif template __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+5{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template int ExternVarTmplDeclInit = 1; d141 2 a142 12 #ifdef GNU // expected-note@@+3{{previous attribute is here}} #endif template __declspec(dllimport) int VarTmplDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+5{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template int VarTmplDeclInit = 1; d241 2 d246 2 a247 11 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} // NB: Both MSVC and Clang issue a warning and make redecl3 dllexport. #ifdef MS // expected-warning@@+4{{'redecl3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void redecl3() {} d269 1 a269 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} d278 1 a278 6 #ifdef MS // expected-warning@@+4{{'friend3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void friend3() {} d450 1 a450 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} a453 1 // expected-note@@+5{{previous attribute is here}} d458 1 a458 1 __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} a462 1 // expected-note@@+5{{previous attribute is here}} d467 1 a467 1 __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} a471 1 // expected-note@@+5{{previous attribute is here}} d476 1 a476 1 __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} d498 2 a499 12 #ifdef MS // expected-warning@@+4{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::Nested::normalDef() {} #ifdef MS // expected-warning@@+4{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::normalDef() {} d505 1 a505 6 #ifdef MS // expected-warning@@+4{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::virtualDef() {} d511 1 a511 6 #ifdef MS // expected-warning@@+4{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::staticDef() {} d623 1 a623 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} d633 1 a633 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) ImportDefaultedDefs &operator=(ImportDefaultedDefs &&); // expected-note{{previous declaration is here}} a638 5 #ifdef MS // expected-warning@@+5{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif d640 1 a640 1 ImportDefaultedDefs::~ImportDefaultedDefs() = default; d651 2 a652 6 #ifdef MS // expected-warning@@+4{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif ImportDefaultedDefs &ImportDefaultedDefs::operator=(ImportDefaultedDefs &&) = default; d973 1 a973 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} d976 1 a976 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} d979 1 a979 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} d1016 1 a1016 7 #ifdef MS // expected-warning@@+5{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template void ImportClassTmplMembers::normalDef() {} d1022 1 a1022 7 #ifdef MS // expected-warning@@+5{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template void ImportClassTmplMembers::virtualDef() {} d1028 1 a1028 7 #ifdef MS // expected-warning@@+5{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template void ImportClassTmplMembers::staticDef() {} @ 1.1.1.6 log @Import Clang pre-4.0.0 r291444. @ text @d18 5 a22 10 __declspec(dllimport) typedef int typedef1; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) int typedef2; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} typedef int __declspec(dllimport) typedef3; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} enum __declspec(dllimport) Enum {}; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} d24 1 a24 2 enum class __declspec(dllimport) EnumClass {}; // expected-warning@@-1{{'dllimport' attribute only applies to variables, functions and classes}} d47 2 a48 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int ExternGlobalDeclInit = 1; d50 2 a51 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'GlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int GlobalDeclInit = 1; d53 2 a54 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int *GlobalDeclChunkAttrInit = 0; d56 2 a57 10 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+4{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif int GlobalDeclAttrInit = 1; d72 2 d138 2 a139 12 #ifdef GNU // expected-note@@+3{{previous attribute is here}} #endif template __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+5{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template int ExternVarTmplDeclInit = 1; d141 2 a142 12 #ifdef GNU // expected-note@@+3{{previous attribute is here}} #endif template __declspec(dllimport) int VarTmplDeclInit; // expected-note{{previous declaration is here}} #ifdef MS // expected-warning@@+5{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template int VarTmplDeclInit = 1; d241 2 d246 2 a247 11 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} // NB: Both MSVC and Clang issue a warning and make redecl3 dllexport. #ifdef MS // expected-warning@@+4{{'redecl3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void redecl3() {} d269 1 a269 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} d278 1 a278 6 #ifdef MS // expected-warning@@+4{{'friend3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void friend3() {} d450 1 a450 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} a453 1 // expected-note@@+5{{previous attribute is here}} d458 1 a458 1 __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} a462 1 // expected-note@@+5{{previous attribute is here}} d467 1 a467 1 __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} a471 1 // expected-note@@+5{{previous attribute is here}} d476 1 a476 1 __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} d498 2 a499 12 #ifdef MS // expected-warning@@+4{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::Nested::normalDef() {} #ifdef MS // expected-warning@@+4{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::normalDef() {} d505 1 a505 6 #ifdef MS // expected-warning@@+4{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::virtualDef() {} d511 1 a511 6 #ifdef MS // expected-warning@@+4{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif void ImportMembers::staticDef() {} d623 1 a623 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} d633 1 a633 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) ImportDefaultedDefs &operator=(ImportDefaultedDefs &&); // expected-note{{previous declaration is here}} a638 5 #ifdef MS // expected-warning@@+5{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif d640 1 a640 1 ImportDefaultedDefs::~ImportDefaultedDefs() = default; d651 2 a652 6 #ifdef MS // expected-warning@@+4{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+2{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif ImportDefaultedDefs &ImportDefaultedDefs::operator=(ImportDefaultedDefs &&) = default; d973 1 a973 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} d976 1 a976 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} d979 1 a979 4 #ifdef GNU // expected-note@@+2{{previous attribute is here}} #endif __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} d1016 1 a1016 7 #ifdef MS // expected-warning@@+5{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template void ImportClassTmplMembers::normalDef() {} d1022 1 a1022 7 #ifdef MS // expected-warning@@+5{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template void ImportClassTmplMembers::virtualDef() {} d1028 1 a1028 7 #ifdef MS // expected-warning@@+5{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}} #else // expected-warning@@+3{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif template void ImportClassTmplMembers::staticDef() {} @ 1.1.1.7 log @Import clang r309604 from branches/release_50 @ text @d399 8 a406 1 #ifdef GNU // MinGW always ignores dllimport on inline functions. d408 1 a408 4 template __declspec(dllimport) inline void inlineFuncTmpl1() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) inline void inlineFuncTmplDecl(); // expected-warning{{'dllimport' attribute ignored on inline function}} d412 1 a412 13 template inline void inlineFuncTmplDef() {} // expected-warning{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}} #else // MSVC drops dllimport when the function template is redeclared without it. (It doesn't warn, but we do.) template __declspec(dllimport) inline void inlineFuncTmpl1() {} template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} template __declspec(dllimport) inline void inlineFuncTmplDecl(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template void inlineFuncTmplDecl() {} // expected-warning{{'inlineFuncTmplDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) void inlineFuncTmplDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template inline void inlineFuncTmplDef() {} // expected-warning{{'inlineFuncTmplDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif d439 1 a439 3 // expected-warning@@+4{{'dllimport' attribute ignored on inline function}} #else // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} a446 3 #ifdef MS // expected-warning@@+2{{'funcTmplFriend5' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif a829 3 #ifdef MS // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} #endif a832 3 #ifdef MS // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} #endif d836 5 a840 5 template __declspec(dllimport) void normalInclass() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) inline void normalInlineDecl(); // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) static void staticInclass() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template __declspec(dllimport) static inline void staticInlineDecl(); // expected-warning{{'dllimport' attribute ignored on inline function}} #else d842 1 a842 1 template __declspec(dllimport) inline void normalInlineDecl(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} d844 1 a844 2 template __declspec(dllimport) static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} #endif d859 1 a860 2 #ifdef GNU // dllimport was ignored above template void ImportMemberTmpl::normalInlineDecl() {} a861 4 #else // dllimport dropped here template void ImportMemberTmpl::normalInlineDecl() {} // expected-warning{{'ImportMemberTmpl::normalInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void ImportMemberTmpl::staticInlineDecl() {} // expected-warning{{'ImportMemberTmpl::staticInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif d864 2 a865 5 template inline void ImportMemberTmpl::normalInlineDef() {} // expected-warning{{ImportMemberTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} template inline void ImportMemberTmpl::staticInlineDef() {} // expected-warning{{ImportMemberTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #else template inline void ImportMemberTmpl::normalInlineDef() {} // expected-warning{{ImportMemberTmpl::normalInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::staticInlineDef() {} // expected-warning{{ImportMemberTmpl::staticInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} d867 2 a1242 3 #ifdef MS // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} #endif a1245 3 #ifdef MS // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} #endif d1250 3 a1252 3 // expected-warning@@+8{{'dllimport' attribute ignored on inline function}} // expected-warning@@+8{{'dllimport' attribute ignored on inline function}} // expected-warning@@+11{{'dllimport' attribute ignored on inline function}} a1254 3 #ifdef MS // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} #endif a1256 3 #ifdef MS // expected-note@@+2{{previous declaration is here}} expected-note@@+2{{previous attribute is here}} #endif d1272 1 a1273 2 #ifdef GNU template template void ImportClsTmplMemTmpl::normalInlineDecl() {} a1274 4 #else template template void ImportClsTmplMemTmpl::normalInlineDecl() {} // expected-warning{{'ImportClsTmplMemTmpl::normalInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template void ImportClsTmplMemTmpl::staticInlineDecl() {} // expected-warning{{'ImportClsTmplMemTmpl::staticInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #endif d1277 2 a1278 5 template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #else template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} d1280 2 @ 1.1.1.7.4.1 log @Sync with HEAD @ text @d19 1 a19 1 // expected-warning@@-1{{'dllimport' attribute only applies to functions, variables, classes, and Objective-C interfaces}} d21 1 a21 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d23 1 a23 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d25 1 a25 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d27 1 a27 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d30 1 a30 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d577 1 a577 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to}} d1150 1 a1150 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to}} @ 1.1.1.7.4.2 log @Mostly merge changes from HEAD upto 20200411 @ text @@ 1.1.1.7.2.1 log @Sync with HEAD @ text @d19 1 a19 1 // expected-warning@@-1{{'dllimport' attribute only applies to functions, variables, classes, and Objective-C interfaces}} d21 1 a21 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d23 1 a23 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d25 1 a25 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d27 1 a27 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d30 1 a30 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d577 1 a577 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to}} d1150 1 a1150 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to}} @ 1.1.1.8 log @Import clang r337282 from trunk @ text @d19 1 a19 1 // expected-warning@@-1{{'dllimport' attribute only applies to functions, variables, classes, and Objective-C interfaces}} d21 1 a21 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d23 1 a23 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d25 1 a25 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d27 1 a27 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d30 1 a30 1 // expected-warning@@-1{{'dllimport' attribute only applies to}} d577 1 a577 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to}} d1150 1 a1150 1 __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to}} @ 1.1.1.9 log @Mark old LLVM instance as dead. @ text @@ 1.1.1.3.4.1 log @file dllimport.cpp was added on branch tls-maxphys on 2014-08-19 23:49:18 +0000 @ text @d1 1092 @ 1.1.1.3.4.2 log @Rebase to HEAD as of a few days ago. @ text @a0 1092 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c++11 -DMS %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c++1y -DMS %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c++1y %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 %s // Helper structs to make templates more expressive. struct ImplicitInst_Imported {}; struct ExplicitDecl_Imported {}; struct ExplicitInst_Imported {}; struct ExplicitSpec_Imported {}; struct ExplicitSpec_Def_Imported {}; struct ExplicitSpec_InlineDef_Imported {}; struct ExplicitSpec_NotImported {}; namespace { struct Internal {}; } // Invalid usage. __declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) int typedef2; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef int __declspec(dllimport) typedef3; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} enum __declspec(dllimport) Enum {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} #if __has_feature(cxx_strong_enums) enum class __declspec(dllimport) EnumClass {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} #endif //===----------------------------------------------------------------------===// // Globals //===----------------------------------------------------------------------===// // Import declaration. __declspec(dllimport) extern int ExternGlobalDecl; // dllimport implies a declaration. __declspec(dllimport) int GlobalDecl; int **__attribute__((dllimport))* GlobalDeclChunkAttr; int GlobalDeclAttr __attribute__((dllimport)); // Not allowed on definitions. __declspec(dllimport) extern int ExternGlobalInit = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) int GlobalInit1 = 1; // expected-error{{definition of dllimport data}} int __declspec(dllimport) GlobalInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int ExternGlobalDeclInit = 1; // expected-warning{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclInit = 1; // expected-warning{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int *GlobalDeclChunkAttrInit = 0; // expected-warning{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclAttrInit = 1; // expected-warning{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations __declspec(dllimport) extern int GlobalRedecl1; __declspec(dllimport) extern int GlobalRedecl1; __declspec(dllimport) int GlobalRedecl2a; __declspec(dllimport) int GlobalRedecl2a; int *__attribute__((dllimport)) GlobalRedecl2b; int *__attribute__((dllimport)) GlobalRedecl2b; int GlobalRedecl2c __attribute__((dllimport)); int GlobalRedecl2c __attribute__((dllimport)); // NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} extern int GlobalRedecl4; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) int ExternalGlobal; } __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}} // expected-error@@-1{{definition of dllimport data}} // Import in local scope. __declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}} void functionScope() { __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}} int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}} int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redefinition of 'LocalRedecl3' with a different type: 'int' vs 'float'}} __declspec(dllimport) int LocalVarDecl; __declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) extern int ExternLocalVarDecl; __declspec(dllimport) extern int ExternLocalVarDef = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllimport'}} } //===----------------------------------------------------------------------===// // Variable templates //===----------------------------------------------------------------------===// #if __has_feature(cxx_variable_templates) // Import declaration. template __declspec(dllimport) extern int ExternVarTmplDecl; // dllimport implies a declaration. template __declspec(dllimport) int VarTmplDecl; // Not allowed on definitions. template __declspec(dllimport) extern int ExternVarTmplInit = 1; // expected-error{{definition of dllimport data}} template __declspec(dllimport) int VarTmplInit1 = 1; // expected-error{{definition of dllimport data}} template int __declspec(dllimport) VarTmplInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. template __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template int ExternVarTmplDeclInit = 1; // expected-warning{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) int VarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template int VarTmplDeclInit = 1; // expected-warning{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations template __declspec(dllimport) extern int VarTmplRedecl1; template __declspec(dllimport) extern int VarTmplRedecl1; template __declspec(dllimport) int VarTmplRedecl2; template __declspec(dllimport) int VarTmplRedecl2; template __declspec(dllimport) extern int VarTmplRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template extern int VarTmplRedecl3; // expected-warning{{'VarTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template extern int VarTmplRedecl4; // expected-note{{previous declaration is here}} template __declspec(dllimport) extern int VarTmplRedecl4; // expected-error{{redeclaration of 'VarTmplRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. template __declspec(dllimport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllimport'}} template __declspec(dllimport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllimport'}} namespace { template __declspec(dllimport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template __declspec(dllimport) int ExternalVarTmpl; } template __declspec(dllimport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{definition of dllimport data}} // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllimport'}} template int VarTmpl; template __declspec(dllimport) int ImportedVarTmpl; // Import implicit instantiation of an imported variable template. int useVarTmpl() { return ImportedVarTmpl; } // Import explicit instantiation declaration of an imported variable template. extern template int ImportedVarTmpl; // An explicit instantiation definition of an imported variable template cannot // be imported because the template must be defined which is illegal. // Import specialization of an imported variable template. template<> __declspec(dllimport) int ImportedVarTmpl; template<> __declspec(dllimport) int ImportedVarTmpl = 1; // expected-error{{definition of dllimport data}} // Not importing specialization of an imported variable template without // explicit dllimport. template<> int ImportedVarTmpl; // Import explicit instantiation declaration of a non-imported variable template. extern template __declspec(dllimport) int VarTmpl; // Import explicit instantiation definition of a non-imported variable template. template __declspec(dllimport) int VarTmpl; // Import specialization of a non-imported variable template. template<> __declspec(dllimport) int VarTmpl; template<> __declspec(dllimport) int VarTmpl = 1; // expected-error{{definition of dllimport data}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Functions //===----------------------------------------------------------------------===// // Import function declaration. Check different placements. __attribute__((dllimport)) void decl1A(); // Sanity check with __attribute__ __declspec(dllimport) void decl1B(); void __attribute__((dllimport)) decl2A(); void __declspec(dllimport) decl2B(); // Not allowed on function definitions. __declspec(dllimport) void def() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // extern "C" extern "C" __declspec(dllimport) void externC(); // Import inline function. __declspec(dllimport) inline void inlineFunc1() {} inline void __attribute__((dllimport)) inlineFunc2() {} __declspec(dllimport) inline void inlineDecl(); void inlineDecl() {} __declspec(dllimport) void inlineDef(); inline void inlineDef() {} // Redeclarations __declspec(dllimport) void redecl1(); __declspec(dllimport) void redecl1(); // NB: MSVC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) void redecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void redecl2(); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}} void redecl5(); // expected-note{{previous declaration is here}} __declspec(dllimport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllimport' attribute}} // Friend functions struct FuncFriend { friend __declspec(dllimport) void friend1(); friend __declspec(dllimport) void friend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend void friend4(); // expected-note{{previous declaration is here}} friend void friend5(); // expected-note{{previous declaration is here}} }; __declspec(dllimport) void friend1(); void friend2(); // expected-warning{{'friend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void friend3() {} // expected-warning{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void friend4(); // expected-error{{redeclaration of 'friend4' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void friend5() {} // expected-error{{redeclaration of 'friend5' cannot add 'dllimport' attribute}} void __declspec(dllimport) friend6(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void __declspec(dllimport) friend7(); struct FuncFriend2 { friend void friend6(); // expected-warning{{'friend6' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} friend void ::friend7(); }; // Implicit declarations can be redeclared with dllimport. __declspec(dllimport) void* operator new(__SIZE_TYPE__ n); // External linkage is required. __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal internalRetFunc(); // expected-error{{'internalRetFunc' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) void internalFunc(); } // expected-error{{'(anonymous namespace)::internalFunc' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) void externalFunc(); } // Import deleted functions. // FIXME: Deleted functions are definitions so a missing inline is diagnosed // here which is irrelevant. But because the delete keyword is parsed later // there is currently no straight-forward way to avoid this diagnostic. __declspec(dllimport) void deletedFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} //===----------------------------------------------------------------------===// // Function templates //===----------------------------------------------------------------------===// // Import function template declaration. Check different placements. template __declspec(dllimport) void funcTmplDecl1(); template void __declspec(dllimport) funcTmplDecl2(); // Import function template definition. template __declspec(dllimport) void funcTmplDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // Import inline function template. template __declspec(dllimport) inline void inlineFuncTmpl1() {} template inline void __attribute__((dllimport)) inlineFuncTmpl2() {} template __declspec(dllimport) inline void inlineFuncTmplDecl(); template void inlineFuncTmplDecl() {} template __declspec(dllimport) void inlineFuncTmplDef(); template inline void inlineFuncTmplDef() {} // Redeclarations template __declspec(dllimport) void funcTmplRedecl1(); template __declspec(dllimport) void funcTmplRedecl1(); template __declspec(dllimport) void funcTmplRedecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template void funcTmplRedecl2(); // expected-warning{{'funcTmplRedecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) void funcTmplRedecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template void funcTmplRedecl3() {} // expected-warning{{'funcTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmplRedecl4(); // expected-note{{previous declaration is here}} template __declspec(dllimport) void funcTmplRedecl4(); // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllimport' attribute}} template void funcTmplRedecl5(); // expected-note{{previous declaration is here}} template __declspec(dllimport) inline void funcTmplRedecl5() {} // expected-error{{redeclaration of 'funcTmplRedecl5' cannot add 'dllimport' attribute}} // Function template friends struct FuncTmplFriend { template friend __declspec(dllimport) void funcTmplFriend1(); template friend __declspec(dllimport) void funcTmplFriend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend __declspec(dllimport) void funcTmplFriend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template friend void funcTmplFriend4(); // expected-note{{previous declaration is here}} template friend __declspec(dllimport) inline void funcTmplFriend5(); }; template __declspec(dllimport) void funcTmplFriend1(); template void funcTmplFriend2(); // expected-warning{{'funcTmplFriend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmplFriend3() {} // expected-warning{{'funcTmplFriend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template __declspec(dllimport) void funcTmplFriend4(); // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllimport' attribute}} template inline void funcTmplFriend5() {} // External linkage is required. template __declspec(dllimport) static int staticFuncTmpl(); // expected-error{{'staticFuncTmpl' must have external linkage when declared 'dllimport'}} template __declspec(dllimport) Internal internalRetFuncTmpl(); // expected-error{{'internalRetFuncTmpl' must have external linkage when declared 'dllimport'}} namespace { template __declspec(dllimport) void internalFuncTmpl(); } // expected-error{{'(anonymous namespace)::internalFuncTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template __declspec(dllimport) void externalFuncTmpl(); } template void funcTmpl() {} template inline void inlineFuncTmpl() {} template __declspec(dllimport) void importedFuncTmplDecl(); template __declspec(dllimport) inline void importedFuncTmpl() {} // Import implicit instantiation of an imported function template. void useFunTmplDecl() { importedFuncTmplDecl(); } void useFunTmplDef() { importedFuncTmpl(); } // Import explicit instantiation declaration of an imported function template. extern template void importedFuncTmpl(); // Import explicit instantiation definition of an imported function template. // NB: MSVC fails this instantiation without explicit dllimport which is most // likely a bug because an implicit instantiation is accepted. template void importedFuncTmpl(); // Import specialization of an imported function template. A definition must be // declared inline. template<> __declspec(dllimport) void importedFuncTmpl(); template<> __declspec(dllimport) void importedFuncTmpl() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} template<> __declspec(dllimport) inline void importedFuncTmpl() {} // Not importing specialization of an imported function template without // explicit dllimport. template<> void importedFuncTmpl() {} // Import explicit instantiation declaration of a non-imported function template. extern template __declspec(dllimport) void funcTmpl(); extern template __declspec(dllimport) void inlineFuncTmpl(); // Import explicit instantiation definition of a non-imported function template. template __declspec(dllimport) void funcTmpl(); template __declspec(dllimport) void inlineFuncTmpl(); // Import specialization of a non-imported function template. A definition must // be declared inline. template<> __declspec(dllimport) void funcTmpl(); template<> __declspec(dllimport) void funcTmpl() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} template<> __declspec(dllimport) inline void funcTmpl() {} //===----------------------------------------------------------------------===// // Class members //===----------------------------------------------------------------------===// // Import individual members of a class. struct ImportMembers { struct Nested { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; void ImportMembers::Nested::normalDef() {} // expected-warning{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void ImportMembers::normalDef() {} // expected-warning{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::normalInlineDef() {} void ImportMembers::normalInlineDecl() {} void ImportMembers::virtualDef() {} // expected-warning{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::virtualInlineDef() {} void ImportMembers::virtualInlineDecl() {} void ImportMembers::staticDef() {} // expected-warning{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} inline void ImportMembers::staticInlineDef() {} void ImportMembers::staticInlineDecl() {} int ImportMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} const int ImportMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} constexpr int ImportMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} // Import on member definitions. struct ImportMemberDefs { __declspec(dllimport) void normalDef(); __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDef(); __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDef(); __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); __declspec(dllimport) static int StaticField; __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) constexpr static int ConstexprField = 1; }; __declspec(dllimport) void ImportMemberDefs::normalDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::normalInlineDef() {} __declspec(dllimport) void ImportMemberDefs::normalInlineDecl() {} __declspec(dllimport) void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::virtualInlineDef() {} __declspec(dllimport) void ImportMemberDefs::virtualInlineDecl() {} __declspec(dllimport) void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void ImportMemberDefs::staticInlineDef() {} __declspec(dllimport) void ImportMemberDefs::staticInlineDecl() {} __declspec(dllimport) int ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) const int ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} // Import special member functions. struct ImportSpecials { __declspec(dllimport) ImportSpecials(); __declspec(dllimport) ~ImportSpecials(); __declspec(dllimport) ImportSpecials(const ImportSpecials&); __declspec(dllimport) ImportSpecials& operator=(const ImportSpecials&); __declspec(dllimport) ImportSpecials(ImportSpecials&&); __declspec(dllimport) ImportSpecials& operator=(ImportSpecials&&); }; // Import deleted member functions. struct ImportDeleted { __declspec(dllimport) ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) void deleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} }; // Import allocation functions. struct ImportAlloc { __declspec(dllimport) void* operator new(__SIZE_TYPE__); __declspec(dllimport) void* operator new[](__SIZE_TYPE__); __declspec(dllimport) void operator delete(void*); __declspec(dllimport) void operator delete[](void*); }; // Import defaulted member functions. struct ImportDefaulted { __declspec(dllimport) ImportDefaulted() = default; __declspec(dllimport) ~ImportDefaulted() = default; __declspec(dllimport) ImportDefaulted(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted& operator=(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted(ImportDefaulted&&) = default; __declspec(dllimport) ImportDefaulted& operator=(ImportDefaulted&&) = default; }; // Import defaulted member function definitions. struct ImportDefaultedDefs { __declspec(dllimport) ImportDefaultedDefs(); __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) inline ImportDefaultedDefs(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs& operator=(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs(ImportDefaultedDefs&&); __declspec(dllimport) ImportDefaultedDefs& operator=(ImportDefaultedDefs&&); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; // Not allowed on definitions. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs() = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} // dllimport cannot be dropped. ImportDefaultedDefs::~ImportDefaultedDefs() = default; // expected-warning{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Import inline declaration and definition. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(const ImportDefaultedDefs&) = default; inline ImportDefaultedDefs& ImportDefaultedDefs::operator=(const ImportDefaultedDefs&) = default; __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(ImportDefaultedDefs&&) = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} ImportDefaultedDefs& ImportDefaultedDefs::operator=(ImportDefaultedDefs&&) = default; // expected-warning{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations cannot add dllimport. struct MemberRedecl { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual void virtualInlineDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; __declspec(dllimport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) int MemberRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} __declspec(dllimport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} __declspec(dllimport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class member templates //===----------------------------------------------------------------------===// struct ImportMemberTmpl { template __declspec(dllimport) void normalDecl(); template __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) void normalInlineDef(); template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticDecl(); template __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) static void staticInclass() {} template __declspec(dllimport) static void staticInlineDef(); template __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template __declspec(dllimport) static int StaticField; template __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstField; template __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template __declspec(dllimport) constexpr static int ConstexprField = 1; template __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template void ImportMemberTmpl::normalDef() {} // expected-warning{{'ImportMemberTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::normalInlineDef() {} template void ImportMemberTmpl::normalInlineDecl() {} template void ImportMemberTmpl::staticDef() {} // expected-warning{{'ImportMemberTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportMemberTmpl::staticInlineDef() {} template void ImportMemberTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template int ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template const int ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template constexpr int ImportMemberTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. struct MemTmplRedecl { template void normalDef(); // expected-note{{previous declaration is here}} template void normalInlineDef(); // expected-note{{previous declaration is here}} template inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template static void staticDef(); // expected-note{{previous declaration is here}} template static void staticInlineDef(); // expected-note{{previous declaration is here}} template static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #if __has_feature(cxx_variable_templates) template static int StaticField; // expected-note{{previous declaration is here}} template static const int StaticConstField; // expected-note{{previous declaration is here}} template constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template __declspec(dllimport) void MemTmplRedecl::normalDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::staticDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void MemTmplRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template __declspec(dllimport) int MemTmplRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) struct MemFunTmpl { template void normalDef() {} template __declspec(dllimport) void importedNormal() {} template static void staticDef() {} template __declspec(dllimport) static void importedStatic() {} }; // Import implicit instantiation of an imported member function template. void useMemFunTmpl() { MemFunTmpl().importedNormal(); MemFunTmpl().importedStatic(); } // Import explicit instantiation declaration of an imported member function // template. extern template void MemFunTmpl::importedNormal(); extern template void MemFunTmpl::importedStatic(); // Import explicit instantiation definition of an imported member function // template. // NB: MSVC fails this instantiation without explicit dllimport. template void MemFunTmpl::importedNormal(); template void MemFunTmpl::importedStatic(); // Import specialization of an imported member function template. template<> __declspec(dllimport) void MemFunTmpl::importedNormal(); template<> __declspec(dllimport) void MemFunTmpl::importedNormal() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::importedNormal() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::importedStatic(); template<> __declspec(dllimport) void MemFunTmpl::importedStatic() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::importedStatic() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif // Not importing specialization of an imported member function template without // explicit dllimport. template<> void MemFunTmpl::importedNormal() {} template<> void MemFunTmpl::importedStatic() {} // Import explicit instantiation declaration of a non-imported member function // template. extern template __declspec(dllimport) void MemFunTmpl::normalDef(); extern template __declspec(dllimport) void MemFunTmpl::staticDef(); // Import explicit instantiation definition of a non-imported member function // template. template __declspec(dllimport) void MemFunTmpl::normalDef(); template __declspec(dllimport) void MemFunTmpl::staticDef(); // Import specialization of a non-imported member function template. template<> __declspec(dllimport) void MemFunTmpl::normalDef(); template<> __declspec(dllimport) void MemFunTmpl::normalDef() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::normalDef() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::staticDef(); template<> __declspec(dllimport) void MemFunTmpl::staticDef() {} // error on mingw template<> __declspec(dllimport) inline void MemFunTmpl::staticDef() {} #ifndef MSABI // expected-error@@-3{{dllimport cannot be applied to non-inline function definition}} #endif #if __has_feature(cxx_variable_templates) struct MemVarTmpl { template static const int StaticVar = 1; template __declspec(dllimport) static const int ImportedStaticVar = 1; }; // Import implicit instantiation of an imported member variable template. int useMemVarTmpl() { return MemVarTmpl::ImportedStaticVar; } // Import explicit instantiation declaration of an imported member variable // template. extern template const int MemVarTmpl::ImportedStaticVar; // An explicit instantiation definition of an imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of an imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar; template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar = 1; // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} // Not importing specialization of a member variable template without explicit // dllimport. template<> const int MemVarTmpl::ImportedStaticVar; // Import explicit instantiation declaration of a non-imported member variable // template. extern template __declspec(dllimport) const int MemVarTmpl::StaticVar; // An explicit instantiation definition of a non-imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of a non-imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::StaticVar; template<> __declspec(dllimport) const int MemVarTmpl::StaticVar = 1; // expected-error@@-1{{definition of dllimport static field not allowed}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Class template members //===----------------------------------------------------------------------===// // Import individual members of a class template. template struct ImportClassTmplMembers { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; // NB: MSVC is inconsistent here and disallows *InlineDef on class templates, // but allows it on classes. We allow both. template void ImportClassTmplMembers::normalDef() {} // expected-warning{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::normalInlineDef() {} template void ImportClassTmplMembers::normalInlineDecl() {} template void ImportClassTmplMembers::virtualDef() {} // expected-warning{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::virtualInlineDef() {} template void ImportClassTmplMembers::virtualInlineDecl() {} template void ImportClassTmplMembers::staticDef() {} // expected-warning{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template inline void ImportClassTmplMembers::staticInlineDef() {} template void ImportClassTmplMembers::staticInlineDecl() {} template int ImportClassTmplMembers::StaticFieldDef; // expected-warning{{definition of dllimport static field}} template const int ImportClassTmplMembers::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}} template constexpr int ImportClassTmplMembers::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}} // Redeclarations cannot add dllimport. template struct CTMR /*ClassTmplMemberRedecl*/ { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual void virtualInlineDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; template __declspec(dllimport) void CTMR::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::virtualDef() {} // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::virtualInlineDecl() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::staticDef() {} // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template __declspec(dllimport) inline void CTMR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}} template __declspec(dllimport) void CTMR::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllimport' attribute}} template __declspec(dllimport) int CTMR::StaticField = 1; // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllimport' attribute}} // expected-warning@@-1{{definition of dllimport static field}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) const int CTMR::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllimport' attribute}} // expected-warning@@-1{{definition of dllimport static field}} // expected-note@@-2{{attribute is here}} template __declspec(dllimport) constexpr int CTMR::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}} // expected-warning@@-1{{definition of dllimport static field}} // expected-note@@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class template member templates //===----------------------------------------------------------------------===// template struct ImportClsTmplMemTmpl { template __declspec(dllimport) void normalDecl(); template __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) void normalInclass() {} template __declspec(dllimport) void normalInlineDef(); template __declspec(dllimport) inline void normalInlineDecl(); template __declspec(dllimport) static void staticDecl(); template __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template __declspec(dllimport) static void staticInclass() {} template __declspec(dllimport) static void staticInlineDef(); template __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template __declspec(dllimport) static int StaticField; template __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstField; template __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template __declspec(dllimport) constexpr static int ConstexprField = 1; template __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template template void ImportClsTmplMemTmpl::normalDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::normalInlineDef() {} template template void ImportClsTmplMemTmpl::normalInlineDecl() {} template template void ImportClsTmplMemTmpl::staticDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template template inline void ImportClsTmplMemTmpl::staticInlineDef() {} template template void ImportClsTmplMemTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template template int ImportClsTmplMemTmpl::StaticFieldDef; // expected-warning{{definition of dllimport static field}} template template const int ImportClsTmplMemTmpl::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}} template template constexpr int ImportClsTmplMemTmpl::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. template struct CTMTR /*ClassTmplMemberTmplRedecl*/ { template void normalDef(); // expected-note{{previous declaration is here}} template void normalInlineDef(); // expected-note{{previous declaration is here}} template inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template static void staticDef(); // expected-note{{previous declaration is here}} template static void staticInlineDef(); // expected-note{{previous declaration is here}} template static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #if __has_feature(cxx_variable_templates) template static int StaticField; // expected-note{{previous declaration is here}} template static const int StaticConstField; // expected-note{{previous declaration is here}} template constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template template __declspec(dllimport) void CTMTR::normalDef() {} // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template template __declspec(dllimport) inline void CTMTR::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::staticDef() {} // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllimport' attribute}} // expected-error@@-1{{dllimport cannot be applied to non-inline function definition}} template template __declspec(dllimport) inline void CTMTR::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}} template template __declspec(dllimport) void CTMTR::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template template __declspec(dllimport) int CTMTR::StaticField = 1; // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllimport' attribute}} // expected-warning@@-1{{definition of dllimport static field}} // expected-note@@-2{{attribute is here}} template template __declspec(dllimport) const int CTMTR::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllimport' attribute}} // expected-warning@@-1{{definition of dllimport static field}} // expected-note@@-2{{attribute is here}} template template __declspec(dllimport) constexpr int CTMTR::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllimport' attribute}} // expected-warning@@-1{{definition of dllimport static field}} // expected-note@@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Classes //===----------------------------------------------------------------------===// class __declspec(dllimport) ClassDecl; class __declspec(dllimport) ClassDef { }; template class ClassTemplate {}; #ifdef MS // expected-note@@+5{{previous attribute is here}} // expected-note@@+4{{previous attribute is here}} // expected-error@@+4{{attribute 'dllexport' cannot be applied to member of 'dllimport' class}} // expected-error@@+4{{attribute 'dllimport' cannot be applied to member of 'dllimport' class}} #endif class __declspec(dllimport) ImportClassWithDllMember { void __declspec(dllexport) foo(); void __declspec(dllimport) bar(); }; #ifdef MS // expected-note@@+5{{previous attribute is here}} // expected-note@@+4{{previous attribute is here}} // expected-error@@+4{{attribute 'dllimport' cannot be applied to member of 'dllexport' class}} // expected-error@@+4{{attribute 'dllexport' cannot be applied to member of 'dllexport' class}} #endif class __declspec(dllexport) ExportClassWithDllMember { void __declspec(dllimport) foo(); void __declspec(dllexport) bar(); }; namespace ImportedExplicitSpecialization { template struct S { static int x; }; template int S::x = sizeof(T); template <> struct __declspec(dllimport) S { static int x; }; // expected-note{{attribute is here}} int S::x = -1; // expected-error{{definition of dllimport static field not allowed}} } namespace PR19988 { // Don't error about applying delete to dllimport member function when instantiating. template struct __declspec(dllimport) S { void foo() = delete; }; S s; } #ifdef MS // expected-warning@@+3{{'dllimport' attribute ignored}} #endif template struct PartiallySpecializedClassTemplate {}; template struct __declspec(dllimport) PartiallySpecializedClassTemplate { void f() {} }; template struct ExpliciallySpecializedClassTemplate {}; template <> struct __declspec(dllimport) ExpliciallySpecializedClassTemplate { void f() {} }; //===----------------------------------------------------------------------===// // Classes with template base classes //===----------------------------------------------------------------------===// template class __declspec(dllexport) ExportedClassTemplate {}; template class __declspec(dllimport) ImportedClassTemplate {}; // ClassTemplate gets imported. class __declspec(dllimport) DerivedFromTemplate : public ClassTemplate {}; // ClassTemplate is already imported. class __declspec(dllimport) DerivedFromTemplate2 : public ClassTemplate {}; // ImportedClassTemplate is expliitly imported. class __declspec(dllimport) DerivedFromImportedTemplate : public ImportedClassTemplate {}; // ExportedClassTemplate is explicitly exported. class __declspec(dllimport) DerivedFromExportedTemplate : public ExportedClassTemplate {}; #ifdef MS // expected-note@@+4{{class template 'ClassTemplate' was instantiated here}} // expected-warning@@+4{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}} // expected-note@@+3{{attribute is here}} #endif class DerivedFromTemplateD : public ClassTemplate {}; class __declspec(dllimport) DerivedFromTemplateD2 : public ClassTemplate {}; #ifdef MS // expected-note@@+4{{class template 'ClassTemplate' was instantiated here}} // expected-warning@@+4{{propagating dll attribute to already instantiated base class template with different dll attribute is not supported}} // expected-note@@+3{{attribute is here}} #endif class __declspec(dllexport) DerivedFromTemplateB : public ClassTemplate {}; class __declspec(dllimport) DerivedFromTemplateB2 : public ClassTemplate {}; template struct ExplicitlySpecializedTemplate { void func() {} }; #ifdef MS // expected-note@@+2{{class template 'ExplicitlySpecializedTemplate' was explicitly specialized here}} #endif template <> struct ExplicitlySpecializedTemplate { void func() {} }; template struct ExplicitlyExportSpecializedTemplate { void func() {} }; template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate { void func() {} }; template struct ExplicitlyImportSpecializedTemplate { void func() {} }; template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate { void func() {} }; template struct ExplicitlyInstantiatedTemplate { void func() {} }; #ifdef MS // expected-note@@+2{{class template 'ExplicitlyInstantiatedTemplate' was instantiated here}} #endif template struct ExplicitlyInstantiatedTemplate; template struct ExplicitlyExportInstantiatedTemplate { void func() {} }; template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate; template struct ExplicitlyImportInstantiatedTemplate { void func() {} }; template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate; #ifdef MS // expected-warning@@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}} // expected-note@@+2{{attribute is here}} #endif struct __declspec(dllimport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate {}; // Base class already specialized with export attribute. struct __declspec(dllimport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate {}; // Base class already specialized with import attribute. struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate {}; #ifdef MS // expected-warning@@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}} // expected-note@@+2{{attribute is here}} #endif struct __declspec(dllimport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate {}; // Base class already instantiated with export attribute. struct __declspec(dllimport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate {}; // Base class already instantiated with import attribute. struct __declspec(dllimport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate {}; @ 1.1.1.1.4.1 log @file dllimport.cpp was added on branch yamt-pagecache on 2014-05-22 16:19:40 +0000 @ text @d1 131 @ 1.1.1.1.4.2 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @a0 131 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -verify -std=c++11 %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -verify -std=c++1y %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -verify -std=c++1y %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 %s // Helper structs to make templates more expressive. struct ImplicitInst_Imported {}; struct ExplicitDecl_Imported {}; struct ExplicitInst_Imported {}; struct ExplicitSpec_Imported {}; struct ExplicitSpec_Def_Imported {}; struct ExplicitSpec_InlineDef_Imported {}; struct ExplicitSpec_NotImported {}; // Invalid usage. __declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables and functions}} typedef __declspec(dllimport) int typedef2; // expected-warning{{'dllimport' attribute only applies to variables and functions}} typedef int __declspec(dllimport) typedef3; // expected-warning{{'dllimport' attribute only applies to variables and functions}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning{{'dllimport' attribute only applies to variables and functions}} enum __declspec(dllimport) Enum {}; // expected-warning{{'dllimport' attribute only applies to variables and functions}} #if __has_feature(cxx_strong_enums) enum class __declspec(dllimport) EnumClass {}; // expected-warning{{'dllimport' attribute only applies to variables and functions}} #endif //===----------------------------------------------------------------------===// // Globals //===----------------------------------------------------------------------===// // Import declaration. __declspec(dllimport) extern int ExternGlobalDecl; // dllimport implies a declaration. __declspec(dllimport) int GlobalDecl; // Not allowed on definitions. __declspec(dllimport) extern int ExternGlobalInit = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) int GlobalInit1 = 1; // expected-error{{definition of dllimport data}} int __declspec(dllimport) GlobalInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. __declspec(dllimport) extern int ExternGlobalDeclInit; int ExternGlobalDeclInit = 1; // expected-error{{definition of dllimport data}} // Redeclarations __declspec(dllimport) extern int GlobalRedecl1; __declspec(dllimport) extern int GlobalRedecl1; // Import in local scope. void functionScope() { __declspec(dllimport) int LocalVarDecl; __declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) extern int ExternLocalVarDecl; __declspec(dllimport) extern int ExternLocalVarDef = 1; // expected-error{{definition of dllimport data}} } //===----------------------------------------------------------------------===// // Functions //===----------------------------------------------------------------------===// // Import function declaration. Check different placements. __attribute__((dllimport)) void decl1A(); // Sanity check with __attribute__ __declspec(dllimport) void decl1B(); void __attribute__((dllimport)) decl2A(); void __declspec(dllimport) decl2B(); // Not allowed on function definitions. __declspec(dllimport) void def() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}} // extern "C" extern "C" __declspec(dllexport) void externC(); // Import inline function. __declspec(dllimport) inline void inlineFunc1() {} // expected-warning{{'dllimport' attribute ignored}} inline void __attribute__((dllimport)) inlineFunc2() {} // expected-warning{{'dllimport' attribute ignored}} // Redeclarations __declspec(dllimport) void redecl1(); __declspec(dllimport) void redecl1(); __declspec(dllimport) void redecl3(); void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} //===----------------------------------------------------------------------===// // Function templates //===----------------------------------------------------------------------===// // Import function template declaration. Check different placements. template __declspec(dllimport) void funcTmplDecl1(); template void __declspec(dllimport) funcTmplDecl2(); // Redeclarations template __declspec(dllimport) void funcTmplRedecl1(); template __declspec(dllimport) void funcTmplRedecl1(); template __declspec(dllimport) void funcTmplRedecl2(); template void funcTmplRedecl2(); template __declspec(dllimport) void funcTmplRedecl3(); template void funcTmplRedecl3() {} // expected-warning{{'funcTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template void funcTmpl() {} template __declspec(dllimport) void importedFuncTmpl(); // Import specialization of an imported function template. A definition must be // declared inline. template<> __declspec(dllimport) void importedFuncTmpl(); template<> __declspec(dllimport) void importedFuncTmpl() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}} template<> __declspec(dllimport) inline void importedFuncTmpl() {} // expected-warning{{'dllimport' attribute ignored}} // Not importing specialization of an imported function template without // explicit dllimport. template<> void importedFuncTmpl() {} // Import explicit instantiation declaration of a non-imported function template. extern template __declspec(dllimport) void funcTmpl(); // Import specialization of a non-imported function template. A definition must // be declared inline. template<> __declspec(dllimport) void funcTmpl(); template<> __declspec(dllimport) void funcTmpl() {} // expected-error{{'dllimport' attribute can be applied only to symbol declaration}} template<> __declspec(dllimport) inline void funcTmpl() {} // expected-warning{{'dllimport' attribute ignored}} @