[flang] Add UNSIGNED (#113504)
[llvm-project.git] / clang / test / CodeGen / dllexport.c
blob4c1143cf5ca4860bfed96faec67935ce87945f0c
1 // RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple i686-windows-gnu -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -triple x86_64-windows-gnu -fms-extensions -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
8 //===----------------------------------------------------------------------===//
9 // Globals
10 //===----------------------------------------------------------------------===//
12 // Declarations are not exported.
13 // CHECK-NOT: @ExternGlobalDecl
14 __declspec(dllexport) extern int ExternGlobalDecl;
16 // dllexport implies a definition.
17 // CHECK-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4
18 __declspec(dllexport) int GlobalDef;
20 // Export definition.
21 // CHECK-DAG: @GlobalInit = dso_local dllexport global i32 1, align 4
22 __declspec(dllexport) int GlobalInit = 1;
24 // Declare, then export definition.
25 // CHECK-DAG: @GlobalDeclInit = dso_local dllexport global i32 1, align 4
26 __declspec(dllexport) extern int GlobalDeclInit;
27 int GlobalDeclInit = 1;
29 // Redeclarations
30 // CHECK-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4
31 __declspec(dllexport) extern int GlobalRedecl1;
32 __declspec(dllexport) int GlobalRedecl1;
34 // CHECK-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4
35 __declspec(dllexport) extern int GlobalRedecl2;
36 int GlobalRedecl2;
40 //===----------------------------------------------------------------------===//
41 // Functions
42 //===----------------------------------------------------------------------===//
44 // Declarations are not exported.
46 // Export function definition.
47 // CHECK-DAG: define dso_local dllexport void @def()
48 __declspec(dllexport) void def(void) {}
50 // Export inline function.
51 // CHECK-DAG: define weak_odr dso_local dllexport void @inlineFunc()
52 // CHECK-DAG: define weak_odr dso_local dllexport void @externInlineFunc()
53 __declspec(dllexport) inline void inlineFunc(void) {}
54 __declspec(dllexport) inline void externInlineFunc(void) {}
55 extern void externInlineFunc(void);
57 // Redeclarations
58 // CHECK-DAG: define dso_local dllexport void @redecl1()
59 __declspec(dllexport) void redecl1(void);
60 __declspec(dllexport) void redecl1(void) {}
62 // CHECK-DAG: define dso_local dllexport void @redecl2()
63 __declspec(dllexport) void redecl2(void);
64 void redecl2(void) {}
68 //===----------------------------------------------------------------------===//
69 // Precedence
70 //===----------------------------------------------------------------------===//
72 // dllexport takes precedence over the dllimport if both are specified.
73 // CHECK-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4
74 // CHECK-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4
75 __attribute__((dllimport, dllexport)) int PrecedenceGlobal1A;
76 __declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B;
78 // CHECK-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4
79 // CHECK-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4
80 __attribute__((dllexport, dllimport)) int PrecedenceGlobal2A;
81 __declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B;
83 // CHECK-DAG: @PrecedenceGlobalRedecl1 = dso_local dllexport global i32 0, align 4
84 __declspec(dllexport) extern int PrecedenceGlobalRedecl1;
85 __declspec(dllimport) int PrecedenceGlobalRedecl1 = 0;
87 // CHECK-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4
88 __declspec(dllimport) extern int PrecedenceGlobalRedecl2;
89 __declspec(dllexport) int PrecedenceGlobalRedecl2;
91 // CHECK-DAG: @PrecedenceGlobalMixed1 = dso_local dllexport global i32 1, align 4
92 __attribute__((dllexport)) extern int PrecedenceGlobalMixed1;
93 __declspec(dllimport) int PrecedenceGlobalMixed1 = 1;
95 // CHECK-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4
96 __attribute__((dllimport)) extern int PrecedenceGlobalMixed2;
97 __declspec(dllexport) int PrecedenceGlobalMixed2;
99 // CHECK-DAG: define dso_local dllexport void @precedence1A()
100 // CHECK-DAG: define dso_local dllexport void @precedence1B()
101 void __attribute__((dllimport, dllexport)) precedence1A(void) {}
102 void __declspec(dllimport) __declspec(dllexport) precedence1B(void) {}
104 // CHECK-DAG: define dso_local dllexport void @precedence2A()
105 // CHECK-DAG: define dso_local dllexport void @precedence2B()
106 void __attribute__((dllexport, dllimport)) precedence2A(void) {}
107 void __declspec(dllexport) __declspec(dllimport) precedence2B(void) {}
109 // CHECK-DAG: define dso_local dllexport void @precedenceRedecl1()
110 void __declspec(dllimport) precedenceRedecl1(void);
111 void __declspec(dllexport) precedenceRedecl1(void) {}
113 // CHECK-DAG: define dso_local dllexport void @precedenceRedecl2()
114 void __declspec(dllexport) precedenceRedecl2(void);
115 void __declspec(dllimport) precedenceRedecl2(void) {}