// 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
// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
// RUN: %clang_cc1 -triple i686-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
// RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -fsyntax-only -fdeclspec -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -fsyntax-only -fdeclspec -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
// RUN: %clang_cc1 -triple x86_64-sie-ps5 -fsyntax-only -fdeclspec -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
// Helper structs to make templates more expressive.
;
;
;
;
;
;
;
// Invalid usage.
__declspec typedef int typedef1;
// expected-warning@-1{{'dllimport' attribute only applies to functions, variables, classes, and Objective-C interfaces}}
typedef __declspec int typedef2;
// expected-warning@-1{{'dllimport' attribute only applies to}}
typedef int __declspec typedef3;
// expected-warning@-1{{'dllimport' attribute only applies to}}
typedef __declspec void ;
// expected-warning@-1{{'dllimport' attribute only applies to}}
;
// expected-warning@-1{{'dllimport' attribute only applies to}}
;
// expected-warning@-1{{'dllimport' attribute only applies to}}
//===----------------------------------------------------------------------===//
// Globals
//===----------------------------------------------------------------------===//
// Import declaration.
__declspec extern int ExternGlobalDecl;
// dllimport implies a declaration.
__declspec int GlobalDecl;
int *** GlobalDeclChunkAttr;
int GlobalDeclAttr ;
// Not allowed on definitions.
__declspec extern int ExternGlobalInit = 1; // expected-error{{definition of dllimport data}}
__declspec int GlobalInit1 = 1; // expected-error{{definition of dllimport data}}
int __declspec GlobalInit2 = 1; // expected-error{{definition of dllimport data}}
// Declare, then reject definition.
// expected-note@+2{{previous attribute is here}}
__declspec extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}}
// expected-warning@+4{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int ExternGlobalDeclInit = 1;
// expected-note@+2{{previous attribute is here}}
__declspec int GlobalDeclInit; // expected-note{{previous declaration is here}}
// expected-warning@+4{{'GlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int GlobalDeclInit = 1;
// expected-note@+2{{previous attribute is here}}
int * GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}}
// expected-warning@+4{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int *GlobalDeclChunkAttrInit = 0;
// expected-note@+2{{previous attribute is here}}
int GlobalDeclAttrInit ; // expected-note{{previous declaration is here}}
// expected-warning@+4{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int GlobalDeclAttrInit = 1;
// Redeclarations
__declspec extern int GlobalRedecl1;
__declspec extern int GlobalRedecl1;
__declspec int GlobalRedecl2a;
__declspec int GlobalRedecl2a;
int * GlobalRedecl2b;
int * GlobalRedecl2b;
int GlobalRedecl2c ;
int GlobalRedecl2c ;
__declspec 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 extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllimport' attribute}}
extern "C"
// External linkage is required.
__declspec static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}}
__declspec Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}}
// expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}}
__declspec auto InternalAutoTypeGlobal = ; // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}}
// expected-error@-1{{definition of dllimport data}}
// Thread local variables are invalid.
__declspec __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
// This doesn't work on MinGW, because there, dllimport on the inline function is ignored.
inline void __declspec
// Import in local scope.
__declspec float LocalRedecl1; // expected-note{{previous declaration is here}}
__declspec float LocalRedecl2; // expected-note{{previous declaration is here}}
__declspec float LocalRedecl3; // expected-note{{previous declaration is here}}
void
//===----------------------------------------------------------------------===//
// Variable templates
//===----------------------------------------------------------------------===//
// Import declaration.
__declspec extern int ExternVarTmplDecl;
// dllimport implies a declaration.
__declspec int VarTmplDecl;
// Not allowed on definitions.
__declspec extern int ExternVarTmplInit = 1; // expected-error{{definition of dllimport data}}
__declspec int VarTmplInit1 = 1; // expected-error{{definition of dllimport data}}
int __declspec VarTmplInit2 = 1; // expected-error{{definition of dllimport data}}
// Declare, then reject definition.
// expected-note@+3{{previous attribute is here}}
__declspec extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}}
// expected-warning@+5{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+3{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int ExternVarTmplDeclInit = 1;
// expected-note@+3{{previous attribute is here}}
__declspec int VarTmplDeclInit; // expected-note{{previous declaration is here}}
// expected-warning@+5{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+3{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int VarTmplDeclInit = 1;
// Redeclarations
__declspec extern int VarTmplRedecl1;
__declspec extern int VarTmplRedecl1;
__declspec int VarTmplRedecl2;
__declspec int VarTmplRedecl2;
__declspec extern int VarTmplRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
extern int VarTmplRedecl3; // expected-warning{{'VarTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
extern int VarTmplRedecl4; // expected-note{{previous declaration is here}}
__declspec extern int VarTmplRedecl4; // expected-error{{redeclaration of 'VarTmplRedecl4' cannot add 'dllimport' attribute}}
// External linkage is required.
__declspec static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllimport'}}
__declspec Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllimport'}}
// expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}}
__declspec auto InternalAutoTypeVarTmpl = ; // expected-error{{definition of dllimport data}} // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllimport'}}
int VarTmpl;
__declspec int ImportedVarTmpl;
// Import implicit instantiation of an imported variable template.
int
// Import explicit instantiation declaration of an imported variable template.
extern ;
// 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.
__declspec int ImportedVarTmpl<ExplicitSpec_Imported>;
__declspec int ImportedVarTmpl<ExplicitSpec_Def_Imported> = 1; // expected-error{{definition of dllimport data}}
// Not importing specialization of an imported variable template without
// explicit dllimport.
int ImportedVarTmpl<ExplicitSpec_NotImported>;
// Import explicit instantiation declaration of a non-imported variable template.
extern ;
// Import explicit instantiation definition of a non-imported variable template.
;
// Import specialization of a non-imported variable template.
__declspec int VarTmpl<ExplicitSpec_Imported>;
__declspec int VarTmpl<ExplicitSpec_Def_Imported> = 1; // expected-error{{definition of dllimport data}}
// __has_feature(cxx_variable_templates)
//===----------------------------------------------------------------------===//
// Functions
//===----------------------------------------------------------------------===//
// Import function declaration. Check different placements.
void ; // Validation check with __attribute__
__declspec void ;
void ;
void __declspec ;
// Not allowed on function definitions.
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
// extern "C"
extern "C" __declspec void ;
// Import inline function.
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
__declspec inline void
inline void
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void ;
void
__declspec void ;
// expected-warning@+2{{'inlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
// Redeclarations
__declspec void ;
__declspec void ;
__declspec void ; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void ; // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
// expected-note@+2{{previous attribute is here}}
__declspec void ; // expected-note{{previous declaration is here}}
// NB: Both MSVC and Clang issue a warning and make redecl3 dllexport.
// expected-warning@+4{{'redecl3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
void ; // expected-note{{previous declaration is here}}
__declspec void ; // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}}
extern "C"
void ; // expected-note{{previous declaration is here}}
__declspec inline void // expected-warning{{redeclaration of 'redecl6' should not add 'dllimport' attribute}}
void ;
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
// Friend functions
;
__declspec void ;
void ; // expected-warning{{'friend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
// expected-warning@+4{{'friend3' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
__declspec void ; // expected-warning{{redeclaration of 'friend4' should not add 'dllimport' attribute}}
__declspec inline void // expected-warning{{redeclaration of 'friend5' should not add 'dllimport' attribute}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
void __declspec ; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void __declspec ;
;
// Implicit declarations can be redeclared with dllimport.
__declspec void* operator new;
// External linkage is required.
__declspec static int ; // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
__declspec Internal ; // expected-error{{'internalRetFunc' must have external linkage when declared 'dllimport'}}
// expected-error{{'(anonymous namespace)::internalFunc' must have external linkage when declared 'dllimport'}}
// 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 void ; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} expected-error{{dllimport cannot be applied to non-inline function definition}}
__declspec inline void ; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
__declspec inline void ; // expected-warning{{'dllimport' attribute ignored on inline function}}
//===----------------------------------------------------------------------===//
// Function templates
//===----------------------------------------------------------------------===//
// Import function template declaration. Check different placements.
__declspec void ;
void __declspec ;
// Import function template definition.
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
// Import inline function template.
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec inline void ; // expected-warning{{'dllimport' attribute ignored on inline function}}
void
__declspec void ;
inline void // expected-warning{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}}
__declspec inline void
inline void
__declspec inline void ; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void // expected-warning{{'inlineFuncTmplDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
__declspec void ; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
inline void // expected-warning{{'inlineFuncTmplDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
// Redeclarations
__declspec void ;
__declspec void ;
__declspec void ; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void ; // expected-warning{{'funcTmplRedecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
__declspec void ; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
void // expected-warning{{'funcTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void ; // expected-note{{previous declaration is here}}
__declspec void ; // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllimport' attribute}}
void ; // expected-note{{previous declaration is here}}
__declspec inline void // expected-error{{redeclaration of 'funcTmplRedecl5' cannot add 'dllimport' attribute}}
// Function template friends
;
__declspec void ;
void ; // expected-warning{{'funcTmplFriend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void // expected-warning{{'funcTmplFriend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
__declspec void ; // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllimport' attribute}}
// expected-warning@+2{{'funcTmplFriend5' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
inline void
// External linkage is required.
__declspec static int ; // expected-error{{'staticFuncTmpl' must have external linkage when declared 'dllimport'}}
__declspec Internal ; // expected-error{{'internalRetFuncTmpl' must have external linkage when declared 'dllimport'}}
// expected-error{{'(anonymous namespace)::internalFuncTmpl' must have external linkage when declared 'dllimport'}}
void
inline void
__declspec void ;
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void
// Import implicit instantiation of an imported function template.
void
void
// Import explicit instantiation declaration of an imported function template.
extern ;
// 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.
;
// Import specialization of an imported function template. A definition must be
// declared inline.
__declspec void ;
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
__declspec inline void
// Not importing specialization of an imported function template without
// explicit dllimport.
void
// Import explicit instantiation declaration of a non-imported function template.
extern ;
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
extern ;
// Import explicit instantiation definition of a non-imported function template.
;
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
;
// Import specialization of a non-imported function template. A definition must
// be declared inline.
__declspec void ;
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void
//===----------------------------------------------------------------------===//
// Class members
//===----------------------------------------------------------------------===//
// Import individual members of a class.
;
// expected-warning@+4{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+4{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+2{{'ImportMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
void
// expected-warning@+4{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+2{{'ImportMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
void
// expected-warning@+4{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+2{{'ImportMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
void
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}}
// expected-error@+2{{definition of dllimport static field not allowed}}
constexpr int ImportMembers::ConstexprFieldDef;
// Import on member definitions.
;
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{dllimport cannot be applied to non-inline function definition}}
__declspec inline void
__declspec void
__declspec inline void
__declspec void
__declspec inline void
__declspec void
__declspec int ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
__declspec const int ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
// expected-error@+3{{definition of dllimport static field not allowed}}
// expected-note@+2{{attribute is here}}
__declspec constexpr int ImportMemberDefs::ConstexprField;
// Import special member functions.
;
// Import deleted member functions.
;
// Import allocation functions.
;
// Import defaulted member functions.
;
// Import defaulted member function definitions.
;
// Not allowed on definitions.
__declspec ; // expected-error{{dllimport cannot be applied to non-inline function definition}}
// expected-warning@+5{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+3{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
// dllimport cannot be dropped.
;
// Import inline declaration and definition.
// expected-error@+3{{redeclaration of 'ImportDefaultedDefs::ImportDefaultedDefs' cannot add 'dllimport' attribute}}
// expected-warning@+3{{'ImportDefaultedDefs::operator=' redeclared inline; 'dllimport' attribute ignored}}
__declspec ;
inline ImportDefaultedDefs& ;
__declspec ; // expected-error{{dllimport cannot be applied to non-inline function definition}}
// expected-warning@+4{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+2{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
ImportDefaultedDefs &;
// Redeclarations cannot add dllimport.
;
__declspec void // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllimport' attribute}}
__declspec void // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllimport' attribute}}
__declspec void // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec 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 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}}
// expected-error@+6{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}}
// expected-error@+5{{definition of dllimport static field not allowed}}
// expected-note@+4{{attribute is here}}
// expected-warning@+2{{attribute declaration must precede definition}}
__declspec constexpr int MemberRedecl::ConstexprField;
//===----------------------------------------------------------------------===//
// Class member templates
//===----------------------------------------------------------------------===//
;
void // expected-warning{{'ImportMemberTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void // expected-warning{{'ImportMemberTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
void
void // expected-warning{{'ImportMemberTmpl::normalInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void // expected-warning{{'ImportMemberTmpl::staticInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
inline void // expected-warning{{ImportMemberTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void // expected-warning{{ImportMemberTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void // expected-warning{{ImportMemberTmpl::normalInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
inline void // expected-warning{{ImportMemberTmpl::staticInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}}
const int ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}}
constexpr int ImportMemberTmpl::ConstexprFieldDef;
// __has_feature(cxx_variable_templates)
// Redeclarations cannot add dllimport.
;
__declspec void // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec inline void // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec void // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllimport' attribute}}
__declspec void // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec inline void // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec void // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllimport' attribute}}
__declspec 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}}
__declspec 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}}
// expected-warning@+1{{attribute declaration must precede definition}}
__declspec constexpr int MemTmplRedecl::ConstexprField;
// __has_feature(cxx_variable_templates)
;
// Import implicit instantiation of an imported member function template.
void
// Import explicit instantiation declaration of an imported member function
// template.
extern ;
extern ;
// Import explicit instantiation definition of an imported member function
// template.
// NB: MSVC fails this instantiation without explicit dllimport.
;
;
// Import specialization of an imported member function template.
__declspec void ;
__declspec void // error on mingw
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void
// FIXME: This should not be an error when targeting MSVC. (PR21406)
// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
__declspec void ;
__declspec void // error on mingw
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void
// FIXME: This should not be an error when targeting MSVC. (PR21406)
// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
// Not importing specialization of an imported member function template without
// explicit dllimport.
void
void
// Import explicit instantiation declaration of a non-imported member function
// template.
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
extern ;
extern ;
// Import explicit instantiation definition of a non-imported member function
// template.
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
;
;
// Import specialization of a non-imported member function template.
__declspec void ;
__declspec void // error on mingw
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void
// FIXME: This should not be an error when targeting MSVC. (PR21406)
// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
__declspec void ;
__declspec void // error on mingw
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
__declspec inline void
// FIXME: This should not be an error when targeting MSVC. (PR21406)
// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
;
// Import implicit instantiation of an imported member variable template.
int
// Import explicit instantiation declaration of an imported member variable
// template.
extern ;
// 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.
__declspec const int MemVarTmpl::ImportedStaticVar<ExplicitSpec_Imported>;
__declspec const int MemVarTmpl::ImportedStaticVar<ExplicitSpec_Def_Imported> = 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.
const int MemVarTmpl::ImportedStaticVar<ExplicitSpec_NotImported>;
// Import explicit instantiation declaration of a non-imported member variable
// template.
extern ;
// 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.
__declspec const int MemVarTmpl::StaticVar<ExplicitSpec_Imported>;
__declspec const int MemVarTmpl::StaticVar<ExplicitSpec_Def_Imported> = 1;
// expected-error@-1{{definition of dllimport static field not allowed}}
// expected-note@-2{{attribute is here}}
// __has_feature(cxx_variable_templates)
//===----------------------------------------------------------------------===//
// Class template members
//===----------------------------------------------------------------------===//
// Import individual members of a class template.
;
// NB: MSVC is inconsistent here and disallows *InlineDef on class templates,
// but allows it on classes. We allow both.
// expected-warning@+5{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+3{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+2{{'ImportClassTmplMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
void
// expected-warning@+5{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+3{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+2{{'ImportClassTmplMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
void
// expected-warning@+5{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
// expected-warning@+3{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
// expected-warning@+2{{'ImportClassTmplMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void
void
int ImportClassTmplMembers<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}}
const int ImportClassTmplMembers<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}}
// expected-warning@+2{{definition of dllimport static field}}
constexpr int ImportClassTmplMembers<T>::ConstexprFieldDef;
// Redeclarations cannot add dllimport.
;
__declspec void // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllimport' attribute}}
__declspec void // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllimport' attribute}}
__declspec void // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec int CTMR<T>::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}}
__declspec const int CTMR<T>::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}}
// expected-error@+6{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}}
// expected-warning@+5{{definition of dllimport static field}}
// expected-note@+4{{attribute is here}}
// expected-warning@+2{{attribute declaration must precede definition}}
__declspec constexpr int CTMR<T>::ConstexprField;
//===----------------------------------------------------------------------===//
// Class template member templates
//===----------------------------------------------------------------------===//
;
void // expected-warning{{'ImportClsTmplMemTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void // expected-warning{{'ImportClsTmplMemTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void
void
void // expected-warning{{'ImportClsTmplMemTmpl::normalInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
void // expected-warning{{'ImportClsTmplMemTmpl::staticInlineDecl' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
inline void // expected-warning{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void // expected-warning{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
inline void // expected-warning{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
inline void // expected-warning{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
int ImportClsTmplMemTmpl<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}}
const int ImportClsTmplMemTmpl<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}}
constexpr int ImportClsTmplMemTmpl<T>::ConstexprFieldDef;
// __has_feature(cxx_variable_templates)
// Redeclarations cannot add dllimport.
;
__declspec void // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllimport' attribute}}
__declspec void // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllimport' attribute}}
// expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
__declspec void // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec inline void // expected-warning{{'dllimport' attribute ignored on inline function}}
__declspec int CTMTR<T>::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}}
__declspec const int CTMTR<T>::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}}
// expected-warning@+1{{attribute declaration must precede definition}}
__declspec constexpr int CTMTR<T>::ConstexprField;
// __has_feature(cxx_variable_templates)
//===----------------------------------------------------------------------===//
// Classes
//===----------------------------------------------------------------------===//
;
;
;
// 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}}
;
// 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}}
;
// expected-warning@+3{{'dllimport' attribute ignored}}
;
;
;
;
//===----------------------------------------------------------------------===//
// Classes with template base classes
//===----------------------------------------------------------------------===//
;
;
// ClassTemplate<int> gets imported.
;
// ClassTemplate<int> is already imported.
;
// ImportedClassTemplate is expliitly imported.
;
// ExportedClassTemplate is explicitly exported.
;
;
// Base class previously implicitly instantiated without attribute; it will get propagated.
;
// Base class has explicit instantiation declaration; the attribute will get propagated.
extern ;
;
;
// The second derived class doesn't change anything, the attribute that was propagated first wins.
;
;
// expected-note@+2{{class template 'ExplicitlySpecializedTemplate<int>' was explicitly specialized here}}
;
;
;
;
;
;
// expected-note@+2{{class template 'ExplicitlyInstantiatedTemplate<int>' was instantiated here}}
;
;
;
;
;
// expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}}
// expected-note@+2{{attribute is here}}
;
// Base class already specialized with export attribute.
;
// Base class already specialized with import attribute.
;
// expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}}
// expected-note@+2{{attribute is here}}
;
// Base class already instantiated with export attribute.
;
// Base class already instantiated with import attribute.
;
;
extern ;
;
//===----------------------------------------------------------------------===//
// Lambdas
//===----------------------------------------------------------------------===//
// The MS ABI doesn't provide a stable mangling for lambdas, so they can't be imported or exported.
// expected-error@+4{{lambda cannot be declared 'dllimport'}}
// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
auto Lambda = __declspec -> bool ;