blob: 9598977e156b8ad92c0293bc53f57045df8c616b [file] [log] [blame]
NAKAMURA Takumie095c652013-01-25 05:58:53 +00001// RUN: %clangxx -target x86_64-unknown-unknown -g -O0 %s -emit-llvm -S -o - | FileCheck %s
Eric Christopherc3ad1002013-01-16 19:54:35 +00002// PR14471
3
David Blaikieced39ec2013-08-17 20:01:53 +00004enum X {
5 Y
6};
Eric Christopherc3ad1002013-01-16 19:54:35 +00007class C
8{
9 static int a;
David Blaikiea89701b2013-01-20 01:19:17 +000010 const static bool const_a = true;
Eric Christopherc3ad1002013-01-16 19:54:35 +000011protected:
12 static int b;
David Blaikiea89701b2013-01-20 01:19:17 +000013 const static float const_b = 3.14;
Eric Christopherc3ad1002013-01-16 19:54:35 +000014public:
15 static int c;
16 const static int const_c = 18;
17 int d;
David Blaikieced39ec2013-08-17 20:01:53 +000018 static X x_a;
Eric Christopherc3ad1002013-01-16 19:54:35 +000019};
20
21int C::a = 4;
22int C::b = 2;
23int C::c = 1;
24
25int main()
26{
27 C instance_C;
28 instance_C.d = 8;
29 return C::c;
30}
31
32// The definition of C::a drives the emission of class C, which is
33// why the definition of "a" comes before the declarations while
34// "b" and "c" come after.
35
Manman Renf1acc312013-08-29 18:51:51 +000036// CHECK: metadata !"_ZTS1X"} ; [ DW_TAG_enumeration_type ] [X]
37// CHECK: metadata !"_ZTS1C"} ; [ DW_TAG_class_type ] [C]
38// CHECK: ![[DECL_A:[0-9]+]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
David Blaikiea89701b2013-01-20 01:19:17 +000039// CHECK: metadata !"const_a", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
Eric Christopherc3ad1002013-01-16 19:54:35 +000040// CHECK: ![[DECL_B:[0-9]+]] {{.*}} metadata !"b", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
David Blaikiea89701b2013-01-20 01:19:17 +000041// CHECK: metadata !"const_b", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
Eric Christopherc3ad1002013-01-16 19:54:35 +000042// CHECK: ![[DECL_C:[0-9]+]] {{.*}} metadata !"c", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [static]
43// CHECK: metadata !"const_c", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [static]
David Blaikieced39ec2013-08-17 20:01:53 +000044// CHECK: metadata !"x_a", {{.*}} [ DW_TAG_member ] [x_a] {{.*}} [static]
Manman Renf1acc312013-08-29 18:51:51 +000045// CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A]]} ; [ DW_TAG_variable ] [a] {{.*}} [def]
Eric Christopherc3ad1002013-01-16 19:54:35 +000046// CHECK: metadata !"b", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def]
47// CHECK: metadata !"c", {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def]