NAKAMURA Takumi | e095c65 | 2013-01-25 05:58:53 +0000 | [diff] [blame] | 1 | // RUN: %clangxx -target x86_64-unknown-unknown -g -O0 %s -emit-llvm -S -o - | FileCheck %s |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 2 | // PR14471 |
| 3 | |
David Blaikie | ced39ec | 2013-08-17 20:01:53 +0000 | [diff] [blame^] | 4 | enum X { |
| 5 | Y |
| 6 | }; |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 7 | class C |
| 8 | { |
| 9 | static int a; |
David Blaikie | a89701b | 2013-01-20 01:19:17 +0000 | [diff] [blame] | 10 | const static bool const_a = true; |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 11 | protected: |
| 12 | static int b; |
David Blaikie | a89701b | 2013-01-20 01:19:17 +0000 | [diff] [blame] | 13 | const static float const_b = 3.14; |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 14 | public: |
| 15 | static int c; |
| 16 | const static int const_c = 18; |
| 17 | int d; |
David Blaikie | ced39ec | 2013-08-17 20:01:53 +0000 | [diff] [blame^] | 18 | static X x_a; |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | int C::a = 4; |
| 22 | int C::b = 2; |
| 23 | int C::c = 1; |
| 24 | |
| 25 | int 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 | |
| 36 | // CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A:[0-9]+]]} ; [ DW_TAG_variable ] [a] {{.*}} [def] |
| 37 | // CHECK: ![[DECL_A]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [private] [static] |
David Blaikie | a89701b | 2013-01-20 01:19:17 +0000 | [diff] [blame] | 38 | // CHECK: metadata !"const_a", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [private] [static] |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 39 | // CHECK: ![[DECL_B:[0-9]+]] {{.*}} metadata !"b", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static] |
David Blaikie | a89701b | 2013-01-20 01:19:17 +0000 | [diff] [blame] | 40 | // CHECK: metadata !"const_b", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static] |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 41 | // CHECK: ![[DECL_C:[0-9]+]] {{.*}} metadata !"c", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [static] |
| 42 | // CHECK: metadata !"const_c", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [static] |
David Blaikie | ced39ec | 2013-08-17 20:01:53 +0000 | [diff] [blame^] | 43 | // CHECK: metadata !"x_a", {{.*}} [ DW_TAG_member ] [x_a] {{.*}} [static] |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 44 | // CHECK: metadata !"b", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def] |
| 45 | // CHECK: metadata !"c", {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def] |