aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/dllimport.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/dllimport.c')
-rw-r--r--test/CodeGen/dllimport.c56
1 files changed, 46 insertions, 10 deletions
diff --git a/test/CodeGen/dllimport.c b/test/CodeGen/dllimport.c
index 32ee81f85924..89dbb9f3461c 100644
--- a/test/CodeGen/dllimport.c
+++ b/test/CodeGen/dllimport.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 %s
-// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 --check-prefix=MO1 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 --check-prefix=GO1 %s
#define JOIN2(x, y) x##y
#define JOIN(x, y) JOIN2(x, y)
@@ -44,6 +44,26 @@ __declspec(dllimport) extern int GlobalRedecl3;
extern int GlobalRedecl3; // dllimport ignored
USEVAR(GlobalRedecl3)
+// Make sure this works even if the decl has been used before it's defined (PR20792).
+// CHECK: @GlobalRedecl4 = common global i32
+__declspec(dllimport) extern int GlobalRedecl4;
+USEVAR(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(dllimport) extern int GlobalRedecl5;
+USEVAR(GlobalRedecl5)
+ extern int GlobalRedecl5; // dllimport ignored
+
+// Redeclaration in local context.
+// CHECK: @GlobalRedecl6 = external dllimport global i32
+__declspec(dllimport) int GlobalRedecl6;
+int functionScope() {
+ extern int GlobalRedecl6; // still dllimport
+ return GlobalRedecl6;
+}
+
//===----------------------------------------------------------------------===//
@@ -59,14 +79,18 @@ __declspec(dllimport) void decl(void);
void (*use_decl)(void) = &decl;
// Import inline function.
-// CHECK-DAG: declare dllimport void @inlineFunc()
-// O1-DAG: define available_externally dllimport void @inlineFunc()
+// MS-DAG: declare dllimport void @inlineFunc()
+// MO1-DAG: define available_externally dllimport void @inlineFunc()
+// GNU-DAG: declare void @inlineFunc()
+// GO1-DAG: define available_externally void @inlineFunc()
__declspec(dllimport) inline void inlineFunc(void) {}
USE(inlineFunc)
// inline attributes
-// CHECK-DAG: declare dllimport void @noinline()
-// O1-DAG: define available_externally dllimport void @noinline()
+// MS-DAG: declare dllimport void @noinline()
+// MO1-DAG: define available_externally dllimport void @noinline()
+// GNU-DAG: declare void @noinline()
+// GO1-DAG: define available_externally void @noinline()
// CHECK-NOT: @alwaysInline()
// O1-NOT: @alwaysInline()
__declspec(dllimport) __attribute__((noinline)) inline void noinline(void) {}
@@ -91,3 +115,15 @@ USE(redecl2)
__declspec(dllimport) void redecl3(void);
void redecl3(void) {} // dllimport ignored
USE(redecl3)
+
+// Make sure this works even if the decl is used before it's defined (PR20792).
+// CHECK-DAG: define void @redecl4()
+__declspec(dllimport) void redecl4(void);
+USE(redecl4)
+ void redecl4(void) {} // dllimport ignored
+
+// FIXME: dllimport is dropped in the AST; this should be reflected in codegen (PR20803).
+// CHECK-DAG: declare dllimport
+__declspec(dllimport) void redecl5(void);
+USE(redecl5)
+ void redecl5(void); // dllimport ignored