// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c99 %s
// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c11 %s
// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c11 %s
// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 %s
// Invalid usage.
__declspec typedef int typedef1;
// expected-warning@-1{{'dllexport' attribute only applies to functions, variables, classes, and Objective-C interfaces}}
typedef __declspec int typedef2;
// expected-warning@-1{{'dllexport' attribute only applies to}}
typedef int __declspec typedef3;
// expected-warning@-1{{'dllexport' attribute only applies to}}
typedef __declspec void ;
// expected-warning@-1{{'dllexport' attribute only applies to}}
;
// expected-warning@-1{{'dllexport' attribute only applies to}}
;
// expected-warning@-1{{'dllexport' attribute only applies to}}
//===----------------------------------------------------------------------===//
// Globals
//===----------------------------------------------------------------------===//
// Export declaration.
__declspec extern int ExternGlobalDecl;
// dllexport implies a definition.
__declspec int GlobalDef;
// Export definition.
__declspec int GlobalInit1 = 1;
int __declspec GlobalInit2 = 1;
// Declare, then export definition.
__declspec extern int GlobalDeclInit;
int GlobalDeclInit = 1;
// Redeclarations
__declspec extern int GlobalRedecl1;
__declspec int GlobalRedecl1;
__declspec extern int GlobalRedecl2;
int GlobalRedecl2;
extern int GlobalRedecl3; // expected-note{{previous declaration is here}}
int
__declspec extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}
extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
__declspec extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}}
// External linkage is required.
__declspec static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}
// Thread local variables are invalid.
__declspec __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
// Export in local scope.
void
//===----------------------------------------------------------------------===//
// Functions
//===----------------------------------------------------------------------===//
// Export function declaration. Check different placements.
void ; // Basic check with __attribute__
__declspec void ;
void ;
void __declspec ;
// Export function definition.
__declspec void
// Export inline function.
__declspec inline void
extern void ;
inline void
extern void ;
// Redeclarations
__declspec void ;
__declspec void ;
__declspec void ;
void ;
__declspec void ;
void
void ; // expected-note{{previous declaration is here}}
void
__declspec void ; // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
void ; // expected-note{{previous declaration is here}}
void
__declspec inline void // expected-error{{redeclaration of 'redecl5' cannot add 'dllexport' attribute}}
// Allow with a warning if the decl hasn't been used yet.
void ; // expected-note{{previous declaration is here}}
__declspec void ; // expected-warning{{redeclaration of 'redecl6' should not add 'dllexport' attribute}}
// External linkage is required.
__declspec static int ; // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
// Static locals don't count as having external linkage.
void
//===----------------------------------------------------------------------===//
// Precedence
//===----------------------------------------------------------------------===//
// dllexport takes precedence over dllimport if both are specified.
extern int PrecedenceExternGlobal1A; // expected-warning{{'dllimport' attribute ignored}}
__declspec __declspec extern int PrecedenceExternGlobal1B; // expected-warning{{'dllimport' attribute ignored}}
extern int PrecedenceExternGlobal2A; // expected-warning{{'dllimport' attribute ignored}}
__declspec __declspec extern int PrecedenceExternGlobal2B; // expected-warning{{'dllimport' attribute ignored}}
int PrecedenceGlobal1A; // expected-warning{{'dllimport' attribute ignored}}
__declspec __declspec int PrecedenceGlobal1B; // expected-warning{{'dllimport' attribute ignored}}
int PrecedenceGlobal2A; // expected-warning{{'dllimport' attribute ignored}}
__declspec __declspec int PrecedenceGlobal2B; // expected-warning{{'dllimport' attribute ignored}}
__declspec extern int PrecedenceExternGlobalRedecl1;
__declspec extern int PrecedenceExternGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}
__declspec extern int PrecedenceExternGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
__declspec extern int PrecedenceExternGlobalRedecl2;
__declspec extern int PrecedenceGlobalRedecl1;
__declspec int PrecedenceGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}
__declspec extern int PrecedenceGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
__declspec int PrecedenceGlobalRedecl2;
void // expected-warning{{'dllimport' attribute ignored}}
void __declspec __declspec // expected-warning{{'dllimport' attribute ignored}}
void // expected-warning{{'dllimport' attribute ignored}}
void __declspec __declspec // expected-warning{{'dllimport' attribute ignored}}
void __declspec ; // expected-warning{{'dllimport' attribute ignored}}
void __declspec
void __declspec ;
void __declspec // expected-warning{{'dllimport' attribute ignored}}