xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/ms-integer-static-data-members.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -DINLINE_INIT -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s --check-prefix=CHECK-INLINE
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s --check-prefix=CHECK-OUTOFLINE
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -DINLINE_INIT -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s --check-prefix=CHECK-INLINE
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc struct S {
7f4a2713aSLionel Sambuc   // For MS ABI, we emit a linkonce_odr definition here, even though it's really just a declaration.
8f4a2713aSLionel Sambuc #ifdef INLINE_INIT
9f4a2713aSLionel Sambuc   static const int x = 5;
10f4a2713aSLionel Sambuc #else
11f4a2713aSLionel Sambuc   static const int x;
12f4a2713aSLionel Sambuc #endif
13f4a2713aSLionel Sambuc };
14f4a2713aSLionel Sambuc 
f()15f4a2713aSLionel Sambuc const int *f() {
16f4a2713aSLionel Sambuc   return &S::x;
17f4a2713aSLionel Sambuc };
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc #ifdef REAL_DEFINITION
20f4a2713aSLionel Sambuc #ifdef INLINE_INIT
21f4a2713aSLionel Sambuc const int S::x;
22f4a2713aSLionel Sambuc #else
23f4a2713aSLionel Sambuc const int S::x = 5;
24f4a2713aSLionel Sambuc #endif
25f4a2713aSLionel Sambuc #endif
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc // Inline initialization.
29f4a2713aSLionel Sambuc // CHECK-INLINE: @"\01?x@S@@2HB" = linkonce_odr constant i32 5, align 4
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc // Out-of-line initialization.
32f4a2713aSLionel Sambuc // CHECK-OUTOFLINE: @"\01?x@S@@2HB" = constant i32 5, align 4
33f4a2713aSLionel Sambuc 
34f4a2713aSLionel Sambuc // No initialization.
35f4a2713aSLionel Sambuc // CHECK: @"\01?x@S@@2HB" = external constant i32
36