From 2b6b257f4e5503a7a2675bdb8735693db769f75c Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:44:14 +0000 Subject: Vendor import of clang release_39 branch r276489: https://llvm.org/svn/llvm-project/cfe/branches/release_39@276489 --- test/SemaCXX/dllimport.cpp | 229 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 184 insertions(+), 45 deletions(-) (limited to 'test/SemaCXX/dllimport.cpp') diff --git a/test/SemaCXX/dllimport.cpp b/test/SemaCXX/dllimport.cpp index 5d8ce78f6cdc..36a8ac625ac3 100644 --- a/test/SemaCXX/dllimport.cpp +++ b/test/SemaCXX/dllimport.cpp @@ -15,13 +15,19 @@ 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}} +__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}} #if __has_feature(cxx_strong_enums) - enum class __declspec(dllimport) EnumClass {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} +enum class __declspec(dllimport) EnumClass {}; +// expected-warning@-1{{'dllimport' attribute only applies to variables, functions and classes}} #endif @@ -44,17 +50,49 @@ __declspec(dllimport) int GlobalInit1 = 1; // expected-error{{definition of dlli 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}} +#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; -__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}} +#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; -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}} +#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; -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}} +#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; // Redeclarations __declspec(dllimport) extern int GlobalRedecl1; @@ -69,8 +107,6 @@ 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}} @@ -135,11 +171,31 @@ template __declspec(dllimport) int VarTmplInit1 = 1; // expected-err 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}} +#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; -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}} +#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; // Redeclarations template __declspec(dllimport) extern int VarTmplRedecl1; @@ -238,13 +294,20 @@ __declspec(dllimport) void inlineDef(); __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}} +#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() {} void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}} @@ -266,7 +329,10 @@ __declspec(dllimport) inline void redecl6() {} // expected-warning{{'dllimport' 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}} +#ifdef GNU +// expected-note@+2{{previous attribute is here}} +#endif + friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} friend void friend4(); // expected-note{{previous declaration is here}} #ifdef MS // expected-note@+2{{previous declaration is here}} @@ -275,7 +341,12 @@ struct FuncFriend { }; __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}} +#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() {} __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}} @@ -447,33 +518,39 @@ template<> __declspec(dllimport) inline void funcTmpl __declspec(dllimport) const int MemVarTmpl::StaticVar struct ImportClassTmplMembers { __declspec(dllimport) void normalDecl(); - __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} +#ifdef GNU +// expected-note@+2{{previous attribute is here}} +#endif + __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) virtual void virtualDecl(); - __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} +#ifdef GNU +// expected-note@+2{{previous attribute is here}} +#endif + __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) static void staticDecl(); - __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} +#ifdef GNU +// expected-note@+2{{previous attribute is here}} +#endif + __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} __declspec(dllimport) static void staticInlineDef(); #ifdef GNU @@ -1013,19 +1134,37 @@ public: // 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}} +#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() {} #ifdef GNU // expected-warning@+2{{'ImportClassTmplMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template inline void ImportClassTmplMembers::normalInlineDef() {} template void ImportClassTmplMembers::normalInlineDecl() {} -template void ImportClassTmplMembers::virtualDef() {} // expected-warning{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} +#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() {} #ifdef GNU // expected-warning@+2{{'ImportClassTmplMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template inline void ImportClassTmplMembers::virtualInlineDef() {} template void ImportClassTmplMembers::virtualInlineDecl() {} -template void ImportClassTmplMembers::staticDef() {} // expected-warning{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} +#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() {} #ifdef GNU // expected-warning@+2{{'ImportClassTmplMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif -- cgit v1.3