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 | |
| 4 | |
| 5 | class C |
| 6 | { |
| 7 | static int a; |
David Blaikie | a89701b | 2013-01-20 01:19:17 +0000 | [diff] [blame] | 8 | const static bool const_a = true; |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 9 | protected: |
| 10 | static int b; |
David Blaikie | a89701b | 2013-01-20 01:19:17 +0000 | [diff] [blame] | 11 | const static float const_b = 3.14; |
Eric Christopher | c3ad100 | 2013-01-16 19:54:35 +0000 | [diff] [blame] | 12 | public: |
| 13 | static int c; |
| 14 | const static int const_c = 18; |
| 15 | int d; |
| 16 | }; |
| 17 | |
| 18 | int C::a = 4; |
| 19 | int C::b = 2; |
| 20 | int C::c = 1; |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | C instance_C; |
| 25 | instance_C.d = 8; |
| 26 | return C::c; |
| 27 | } |
| 28 | |
| 29 | // The definition of C::a drives the emission of class C, which is |
| 30 | // why the definition of "a" comes before the declarations while |
| 31 | // "b" and "c" come after. |
| 32 | |
| 33 | // CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A:[0-9]+]]} ; [ DW_TAG_variable ] [a] {{.*}} [def] |
| 34 | // 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] | 35 | // 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] | 36 | // 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] | 37 | // 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] | 38 | // CHECK: ![[DECL_C:[0-9]+]] {{.*}} metadata !"c", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [static] |
| 39 | // CHECK: metadata !"const_c", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [static] |
| 40 | // CHECK: metadata !"b", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def] |
| 41 | // CHECK: metadata !"c", {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def] |