// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple i686-windows-gnu -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-windows-gnu -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
//===----------------------------------------------------------------------===//
// Globals
//===----------------------------------------------------------------------===//
// Declarations are not exported.
// CHECK-NOT: @ExternGlobalDecl
__declspec extern int ExternGlobalDecl;
// dllexport implies a definition.
// CHECK-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4
__declspec int GlobalDef;
// Export definition.
// CHECK-DAG: @GlobalInit = dso_local dllexport global i32 1, align 4
__declspec int GlobalInit = 1;
// Declare, then export definition.
// CHECK-DAG: @GlobalDeclInit = dso_local dllexport global i32 1, align 4
__declspec extern int GlobalDeclInit;
int GlobalDeclInit = 1;
// Redeclarations
// CHECK-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4
__declspec extern int GlobalRedecl1;
__declspec int GlobalRedecl1;
// CHECK-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4
__declspec extern int GlobalRedecl2;
int GlobalRedecl2;
//===----------------------------------------------------------------------===//
// Functions
//===----------------------------------------------------------------------===//
// Declarations are not exported.
// Export function definition.
// CHECK-DAG: define dso_local dllexport void @def()
__declspec void
// Export inline function.
// CHECK-DAG: define weak_odr dso_local dllexport void @inlineFunc()
// CHECK-DAG: define weak_odr dso_local dllexport void @externInlineFunc()
__declspec inline void
__declspec inline void
extern void ;
// Redeclarations
// CHECK-DAG: define dso_local dllexport void @redecl1()
__declspec void ;
__declspec void
// CHECK-DAG: define dso_local dllexport void @redecl2()
__declspec void ;
void
//===----------------------------------------------------------------------===//
// Precedence
//===----------------------------------------------------------------------===//
// dllexport takes precedence over the dllimport if both are specified.
// CHECK-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4
// CHECK-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4
int PrecedenceGlobal1A;
__declspec __declspec int PrecedenceGlobal1B;
// CHECK-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4
// CHECK-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4
int PrecedenceGlobal2A;
__declspec __declspec int PrecedenceGlobal2B;
// CHECK-DAG: @PrecedenceGlobalRedecl1 = dso_local dllexport global i32 0, align 4
__declspec extern int PrecedenceGlobalRedecl1;
__declspec int PrecedenceGlobalRedecl1 = 0;
// CHECK-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4
__declspec extern int PrecedenceGlobalRedecl2;
__declspec int PrecedenceGlobalRedecl2;
// CHECK-DAG: @PrecedenceGlobalMixed1 = dso_local dllexport global i32 1, align 4
extern int PrecedenceGlobalMixed1;
__declspec int PrecedenceGlobalMixed1 = 1;
// CHECK-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4
extern int PrecedenceGlobalMixed2;
__declspec int PrecedenceGlobalMixed2;
// CHECK-DAG: define dso_local dllexport void @precedence1A()
// CHECK-DAG: define dso_local dllexport void @precedence1B()
void
void __declspec __declspec
// CHECK-DAG: define dso_local dllexport void @precedence2A()
// CHECK-DAG: define dso_local dllexport void @precedence2B()
void
void __declspec __declspec
// CHECK-DAG: define dso_local dllexport void @precedenceRedecl1()
void __declspec ;
void __declspec
// CHECK-DAG: define dso_local dllexport void @precedenceRedecl2()
void __declspec ;
void __declspec