Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s |
| 2 | // RUN: %clang_cc1 -DINLINE_INIT -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s --check-prefix=CHECK-INLINE |
| 3 | // RUN: %clang_cc1 -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s --check-prefix=CHECK-OUTOFLINE |
| 4 | // RUN: %clang_cc1 -DINLINE_INIT -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s --check-prefix=CHECK-INLINE |
Bill Wendling | 0cbb3ed | 2013-11-21 05:19:27 +0000 | [diff] [blame] | 5 | |
| 6 | struct S { |
| 7 | // For MS ABI, we emit a linkonce_odr definition here, even though it's really just a declaration. |
| 8 | #ifdef INLINE_INIT |
| 9 | static const int x = 5; |
| 10 | #else |
| 11 | static const int x; |
| 12 | #endif |
| 13 | }; |
| 14 | |
| 15 | const int *f() { |
| 16 | return &S::x; |
| 17 | }; |
| 18 | |
| 19 | #ifdef REAL_DEFINITION |
| 20 | #ifdef INLINE_INIT |
| 21 | const int S::x; |
| 22 | #else |
| 23 | const int S::x = 5; |
| 24 | #endif |
| 25 | #endif |
| 26 | |
| 27 | |
| 28 | // Inline initialization. |
| 29 | // CHECK-INLINE: @"\01?x@S@@2HB" = linkonce_odr constant i32 5, align 4 |
| 30 | |
| 31 | // Out-of-line initialization. |
| 32 | // CHECK-OUTOFLINE: @"\01?x@S@@2HB" = constant i32 5, align 4 |
| 33 | |
| 34 | // No initialization. |
| 35 | // CHECK: @"\01?x@S@@2HB" = external constant i32 |