blob: b2bfc92d264c058383e725986710b88683437851 [file] [log] [blame]
Hans Wennborg56fc62b2014-07-17 20:25:23 +00001// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
Hans Wennborgfeedf852013-11-21 00:15:56 +00002
3struct S {
Alexey Bataev15413ea2015-05-20 11:57:02 +00004 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 Wennborgfeedf852013-11-21 00:15:56 +000011};
12
Alexey Bataev15413ea2015-05-20 11:57:02 +000013const int *foo1() {
14 return &S::NoInit_Ref;
Hans Wennborgfeedf852013-11-21 00:15:56 +000015};
16
Alexey Bataev15413ea2015-05-20 11:57:02 +000017const int *foo2() {
18 return &S::Inline_NotDef_Ref;
19};
Hans Wennborgfeedf852013-11-21 00:15:56 +000020
Alexey Bataev15413ea2015-05-20 11:57:02 +000021const int *foo3() {
22 return &S::Inline_Def_Ref;
23};
Hans Wennborgfeedf852013-11-21 00:15:56 +000024
Alexey Bataev15413ea2015-05-20 11:57:02 +000025const int *foo4() {
26 return &S::OutOfLine_Def_Ref;
27};
Hans Wennborgfeedf852013-11-21 00:15:56 +000028
Alexey Bataev15413ea2015-05-20 11:57:02 +000029const int S::Inline_Def_NotRef;
30const int S::Inline_Def_Ref;
31const int S::OutOfLine_Def_NotRef = 5;
32const int S::OutOfLine_Def_Ref = 5;
33
Hans Wennborgfeedf852013-11-21 00:15:56 +000034
35// No initialization.
Alexey Bataev15413ea2015-05-20 11:57:02 +000036// 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 Majnemerfac52432015-10-19 23:22:49 +000045// CHECK-NOT: @"\01?Inline_Def_NotRef@S@@2HB" = constant i32 5, align 4
Alexey Bataev15413ea2015-05-20 11:57:02 +000046
47// Inline initialization, real definiton, referenced.
David Majnemerfac52432015-10-19 23:22:49 +000048// CHECK-DAG: @"\01?Inline_Def_Ref@S@@2HB" = linkonce_odr constant i32 5, comdat, align 4
Alexey Bataev15413ea2015-05-20 11:57:02 +000049
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