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