Hans Wennborg | 56fc62b | 2014-07-17 20:25:23 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 2 | |
| 3 | struct S { |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 4 | static const int NoInit_Ref; |
| 5 | static const int Inline_NotDef_NotRef = 5; |
| 6 | static const int Inline_NotDef_Ref = 5; |
| 7 | static const int Inline_Def_NotRef = 5; |
| 8 | static const int Inline_Def_Ref = 5; |
| 9 | static const int OutOfLine_Def_NotRef; |
| 10 | static const int OutOfLine_Def_Ref; |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 11 | }; |
| 12 | |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 13 | const int *foo1() { |
| 14 | return &S::NoInit_Ref; |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 15 | }; |
| 16 | |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 17 | const int *foo2() { |
| 18 | return &S::Inline_NotDef_Ref; |
| 19 | }; |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 20 | |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 21 | const int *foo3() { |
| 22 | return &S::Inline_Def_Ref; |
| 23 | }; |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 24 | |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 25 | const int *foo4() { |
| 26 | return &S::OutOfLine_Def_Ref; |
| 27 | }; |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 28 | |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 29 | const int S::Inline_Def_NotRef; |
| 30 | const int S::Inline_Def_Ref; |
| 31 | const int S::OutOfLine_Def_NotRef = 5; |
| 32 | const int S::OutOfLine_Def_Ref = 5; |
| 33 | |
Hans Wennborg | feedf85 | 2013-11-21 00:15:56 +0000 | [diff] [blame] | 34 | |
| 35 | // No initialization. |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 36 | // CHECK-DAG: @"\01?NoInit_Ref@S@@2HB" = external constant i32 |
| 37 | |
| 38 | // Inline initialization, no real definiton, not referenced. |
| 39 | // CHECK-NOT: @"\01?Inline_NotDef_NotRef@S@@2HB" = {{.*}} constant i32 5 |
| 40 | |
| 41 | // Inline initialization, no real definiton, referenced. |
| 42 | // CHECK-DAG: @"\01?Inline_NotDef_Ref@S@@2HB" = linkonce_odr constant i32 5, comdat, align 4 |
| 43 | |
| 44 | // Inline initialization, real definiton, not referenced. |
David Majnemer | fac5243 | 2015-10-19 23:22:49 +0000 | [diff] [blame] | 45 | // CHECK-NOT: @"\01?Inline_Def_NotRef@S@@2HB" = constant i32 5, align 4 |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 46 | |
| 47 | // Inline initialization, real definiton, referenced. |
David Majnemer | fac5243 | 2015-10-19 23:22:49 +0000 | [diff] [blame] | 48 | // CHECK-DAG: @"\01?Inline_Def_Ref@S@@2HB" = linkonce_odr constant i32 5, comdat, align 4 |
Alexey Bataev | 15413ea | 2015-05-20 11:57:02 +0000 | [diff] [blame] | 49 | |
| 50 | // Out-of-line initialization. |
| 51 | // CHECK-DAG: @"\01?OutOfLine_Def_NotRef@S@@2HB" = constant i32 5, align 4 |
| 52 | // CHECK-DAG: @"\01?OutOfLine_Def_Ref@S@@2HB" = constant i32 5, align 4 |