1 | // RUN: %clang_cc1 -x c -emit-llvm -triple arm-none-eabi -o - %s | FileCheck %s |
2 | |
3 | // Test that section attributes are attached to C tentative definitions as per |
4 | // '#pragma clang section' directives. |
5 | |
6 | #pragma clang section bss = ".bss.1" |
7 | int x; // bss.1 |
8 | |
9 | #pragma clang section bss = "" |
10 | int x; // stays in .bss.1 |
11 | int y; // not assigned a section attribute |
12 | int z; // not assigned a section attribute |
13 | |
14 | #pragma clang section bss = ".bss.2" |
15 | int x; // stays in .bss.1 |
16 | int y; // .bss.2 |
17 | |
18 | // Test the same for `const` declarations. |
19 | #pragma clang section rodata = ".rodata.1" |
20 | const int cx; // rodata.1 |
21 | |
22 | #pragma clang section rodata = "" |
23 | const int cx; // stays in .rodata.1 |
24 | const int cy; // not assigned a section attribute |
25 | const int cz; // not assigned a rodata section attribute |
26 | |
27 | #pragma clang section rodata = ".rodata.2" |
28 | const int cx; // stays in .rodata.1 |
29 | const int cy; // .rodata.2 |
30 | |
31 | // CHECK: @x = global i32 0, align 4 #0 |
32 | // CHECK: @y = global i32 0, align 4 #1 |
33 | // CHECK: @z = common global i32 0, align 4 |
34 | // CHECK: @cx = constant i32 0, align 4 #2 |
35 | // CHECK: @cy = constant i32 0, align 4 #3 |
36 | // CHECK: @cz = constant i32 0, align 4 #1 |
37 | |
38 | // CHECK: attributes #0 = { "bss-section"=".bss.1" } |
39 | // CHECK: attributes #1 = { "bss-section"=".bss.2" } |
40 | // CHECK: attributes #2 = { "bss-section"=".bss.2" "rodata-section"=".rodata.1" } |
41 | // CHECK: attributes #3 = { "bss-section"=".bss.2" "rodata-section"=".rodata.2" } |
42 | |