// RUN: %clang_cc1 -no-opaque-pointers -triple i686-windows-msvc -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-msvc -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
// RUN: %clang_cc1 -no-opaque-pointers -triple i686-windows-gnu -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-gnu -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
// RUN: %clang_cc1 -no-opaque-pointers -triple i686-windows-msvc -fms-extensions -emit-llvm -std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 --check-prefix=MO1 %s
// RUN: %clang_cc1 -no-opaque-pointers -triple i686-windows-gnu -fms-extensions -emit-llvm -std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 --check-prefix=GO1 %s
//===----------------------------------------------------------------------===//
// Globals
//===----------------------------------------------------------------------===//
// Import declaration.
// CHECK: @ExternGlobalDecl = external dllimport global i32
__declspec extern int ExternGlobalDecl;
// dllimport implies a declaration.
// CHECK: @GlobalDecl = external dllimport global i32
__declspec int GlobalDecl;
// Redeclarations
// CHECK: @GlobalRedecl1 = external dllimport global i32
__declspec extern int GlobalRedecl1;
__declspec extern int GlobalRedecl1;
// CHECK: @GlobalRedecl2 = external dllimport global i32
__declspec int GlobalRedecl2;
__declspec int GlobalRedecl2;
// NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC
// and drop the dllimport with a warning.
// MS: @GlobalRedecl3 = external dso_local global i32
// GNU: @GlobalRedecl3 = external global i32
__declspec extern int GlobalRedecl3;
extern int GlobalRedecl3; // dllimport ignored
// Make sure this works even if the decl has been used before it's defined (PR20792).
// MS: @GlobalRedecl4 = dso_local dllexport global i32
// GNU: @GlobalRedecl4 = dso_local global i32
__declspec extern int GlobalRedecl4;
int GlobalRedecl4; // dllimport ignored
// FIXME: dllimport is dropped in the AST; this should be reflected in codegen (PR02803).
// CHECK: @GlobalRedecl5 = external dllimport global i32
__declspec extern int GlobalRedecl5;
extern int GlobalRedecl5; // dllimport ignored
// Redeclaration in local context.
// CHECK: @GlobalRedecl6 = external dllimport global i32
__declspec int GlobalRedecl6;
int
//===----------------------------------------------------------------------===//
// Functions
//===----------------------------------------------------------------------===//
// Import function declaration.
// CHECK-DAG: declare dllimport void @decl()
__declspec void ;
// Initialize use_decl with the address of the thunk.
// CHECK-DAG: @use_decl = dso_local global void ()* @decl
= &decl;
// Import inline function.
// MS-DAG: declare dllimport void @inlineFunc()
// MO1-DAG: declare dllimport void @inlineFunc()
// GNU-DAG: declare dso_local void @inlineFunc()
// GO1-DAG: declare dso_local void @inlineFunc()
__declspec inline void
// inline attributes
// MS-DAG: declare dllimport void @noinline()
// MO1-DAG: declare dllimport void @noinline()
// GNU-DAG: declare dso_local void @noinline()
// GO1-DAG: declare dso_local void @noinline()
// CHECK-NOT: @alwaysInline()
// O1-NOT: @alwaysInline()
__declspec inline void
__declspec inline void
// Redeclarations
// CHECK-DAG: declare dllimport void @redecl1()
__declspec void ;
__declspec void ;
// NB: MSVC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC
// and drop the dllimport with a warning.
// CHECK-DAG: declare dso_local void @redecl2()
__declspec void ;
void ;
// MS: define dso_local dllexport void @redecl3()
// GNU: define dso_local void @redecl3()
__declspec void ;
void // dllimport ignored
// Make sure this works even if the decl is used before it's defined (PR20792).
// MS: define dso_local dllexport void @redecl4()
// GNU: define dso_local void @redecl4()
__declspec void ;
void // dllimport ignored
// FIXME: dllimport is dropped in the AST; this should be reflected in codegen (PR20803).
// CHECK-DAG: declare dllimport
__declspec void ;
void ; // dllimport ignored