1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc
7*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
9*0a6a1f1dSLionel Sambuc // Globals
10*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
11*0a6a1f1dSLionel Sambuc
12*0a6a1f1dSLionel Sambuc // Declarations are not exported.
13*0a6a1f1dSLionel Sambuc // CHECK-NOT: @ExternGlobalDecl
14*0a6a1f1dSLionel Sambuc __declspec(dllexport) extern int ExternGlobalDecl;
15*0a6a1f1dSLionel Sambuc
16*0a6a1f1dSLionel Sambuc // dllexport implies a definition.
17*0a6a1f1dSLionel Sambuc // CHECK-DAG: @GlobalDef = common dllexport global i32 0, align 4
18*0a6a1f1dSLionel Sambuc __declspec(dllexport) int GlobalDef;
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuc // Export definition.
21*0a6a1f1dSLionel Sambuc // CHECK-DAG: @GlobalInit = dllexport global i32 1, align 4
22*0a6a1f1dSLionel Sambuc __declspec(dllexport) int GlobalInit = 1;
23*0a6a1f1dSLionel Sambuc
24*0a6a1f1dSLionel Sambuc // Declare, then export definition.
25*0a6a1f1dSLionel Sambuc // CHECK-DAG: @GlobalDeclInit = dllexport global i32 1, align 4
26*0a6a1f1dSLionel Sambuc __declspec(dllexport) extern int GlobalDeclInit;
27*0a6a1f1dSLionel Sambuc int GlobalDeclInit = 1;
28*0a6a1f1dSLionel Sambuc
29*0a6a1f1dSLionel Sambuc // Redeclarations
30*0a6a1f1dSLionel Sambuc // CHECK-DAG: @GlobalRedecl1 = common dllexport global i32 0, align 4
31*0a6a1f1dSLionel Sambuc __declspec(dllexport) extern int GlobalRedecl1;
32*0a6a1f1dSLionel Sambuc __declspec(dllexport) int GlobalRedecl1;
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc // CHECK-DAG: @GlobalRedecl2 = common dllexport global i32 0, align 4
35*0a6a1f1dSLionel Sambuc __declspec(dllexport) extern int GlobalRedecl2;
36*0a6a1f1dSLionel Sambuc int GlobalRedecl2;
37*0a6a1f1dSLionel Sambuc
38*0a6a1f1dSLionel Sambuc
39*0a6a1f1dSLionel Sambuc
40*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
41*0a6a1f1dSLionel Sambuc // Functions
42*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
43*0a6a1f1dSLionel Sambuc
44*0a6a1f1dSLionel Sambuc // Declarations are not exported.
45*0a6a1f1dSLionel Sambuc
46*0a6a1f1dSLionel Sambuc // Export function definition.
47*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @def()
def(void)48*0a6a1f1dSLionel Sambuc __declspec(dllexport) void def(void) {}
49*0a6a1f1dSLionel Sambuc
50*0a6a1f1dSLionel Sambuc // Export inline function.
51*0a6a1f1dSLionel Sambuc // CHECK-DAG: define weak_odr dllexport void @inlineFunc()
52*0a6a1f1dSLionel Sambuc // CHECK-DAG: define weak_odr dllexport void @externInlineFunc()
inlineFunc(void)53*0a6a1f1dSLionel Sambuc __declspec(dllexport) inline void inlineFunc(void) {}
externInlineFunc(void)54*0a6a1f1dSLionel Sambuc __declspec(dllexport) inline void externInlineFunc(void) {}
55*0a6a1f1dSLionel Sambuc extern void externInlineFunc(void);
56*0a6a1f1dSLionel Sambuc
57*0a6a1f1dSLionel Sambuc // Redeclarations
58*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @redecl1()
59*0a6a1f1dSLionel Sambuc __declspec(dllexport) void redecl1(void);
redecl1(void)60*0a6a1f1dSLionel Sambuc __declspec(dllexport) void redecl1(void) {}
61*0a6a1f1dSLionel Sambuc
62*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @redecl2()
63*0a6a1f1dSLionel Sambuc __declspec(dllexport) void redecl2(void);
redecl2(void)64*0a6a1f1dSLionel Sambuc void redecl2(void) {}
65*0a6a1f1dSLionel Sambuc
66*0a6a1f1dSLionel Sambuc
67*0a6a1f1dSLionel Sambuc
68*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
69*0a6a1f1dSLionel Sambuc // Precedence
70*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
71*0a6a1f1dSLionel Sambuc
72*0a6a1f1dSLionel Sambuc // dllexport takes precedence over the dllimport if both are specified.
73*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobal1A = common dllexport global i32 0, align 4
74*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobal1B = common dllexport global i32 0, align 4
75*0a6a1f1dSLionel Sambuc __attribute__((dllimport, dllexport)) int PrecedenceGlobal1A;
76*0a6a1f1dSLionel Sambuc __declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B;
77*0a6a1f1dSLionel Sambuc
78*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobal2A = common dllexport global i32 0, align 4
79*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobal2B = common dllexport global i32 0, align 4
80*0a6a1f1dSLionel Sambuc __attribute__((dllexport, dllimport)) int PrecedenceGlobal2A;
81*0a6a1f1dSLionel Sambuc __declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
82*0a6a1f1dSLionel Sambuc
83*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobalRedecl1 = dllexport global i32 0, align 4
84*0a6a1f1dSLionel Sambuc __declspec(dllexport) extern int PrecedenceGlobalRedecl1;
85*0a6a1f1dSLionel Sambuc __declspec(dllimport) int PrecedenceGlobalRedecl1 = 0;
86*0a6a1f1dSLionel Sambuc
87*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobalRedecl2 = common dllexport global i32 0, align 4
88*0a6a1f1dSLionel Sambuc __declspec(dllimport) extern int PrecedenceGlobalRedecl2;
89*0a6a1f1dSLionel Sambuc __declspec(dllexport) int PrecedenceGlobalRedecl2;
90*0a6a1f1dSLionel Sambuc
91*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobalMixed1 = dllexport global i32 1, align 4
92*0a6a1f1dSLionel Sambuc __attribute__((dllexport)) extern int PrecedenceGlobalMixed1;
93*0a6a1f1dSLionel Sambuc __declspec(dllimport) int PrecedenceGlobalMixed1 = 1;
94*0a6a1f1dSLionel Sambuc
95*0a6a1f1dSLionel Sambuc // CHECK-DAG: @PrecedenceGlobalMixed2 = common dllexport global i32 0, align 4
96*0a6a1f1dSLionel Sambuc __attribute__((dllimport)) extern int PrecedenceGlobalMixed2;
97*0a6a1f1dSLionel Sambuc __declspec(dllexport) int PrecedenceGlobalMixed2;
98*0a6a1f1dSLionel Sambuc
99*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @precedence1A()
100*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @precedence1B()
precedence1A(void)101*0a6a1f1dSLionel Sambuc void __attribute__((dllimport, dllexport)) precedence1A(void) {}
precedence1B(void)102*0a6a1f1dSLionel Sambuc void __declspec(dllimport) __declspec(dllexport) precedence1B(void) {}
103*0a6a1f1dSLionel Sambuc
104*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @precedence2A()
105*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @precedence2B()
precedence2A(void)106*0a6a1f1dSLionel Sambuc void __attribute__((dllexport, dllimport)) precedence2A(void) {}
precedence2B(void)107*0a6a1f1dSLionel Sambuc void __declspec(dllexport) __declspec(dllimport) precedence2B(void) {}
108*0a6a1f1dSLionel Sambuc
109*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @precedenceRedecl1()
110*0a6a1f1dSLionel Sambuc void __declspec(dllimport) precedenceRedecl1(void);
precedenceRedecl1(void)111*0a6a1f1dSLionel Sambuc void __declspec(dllexport) precedenceRedecl1(void) {}
112*0a6a1f1dSLionel Sambuc
113*0a6a1f1dSLionel Sambuc // CHECK-DAG: define dllexport void @precedenceRedecl2()
114*0a6a1f1dSLionel Sambuc void __declspec(dllexport) precedenceRedecl2(void);
precedenceRedecl2(void)115*0a6a1f1dSLionel Sambuc void __declspec(dllimport) precedenceRedecl2(void) {}
116