1 | // RUN: %clang_cc1 -emit-llvm -triple arm-none-eabi -o - %s | FileCheck %s |
2 | |
3 | // Test interaction between __attribute__((section())) and '#pragma clang |
4 | // section' directives. The attribute should always have higher priority than |
5 | // the pragma. |
6 | |
7 | // Text tests. |
8 | #pragma clang section text=".ext_fun_pragma" |
9 | void ext_fun(void) __attribute__((section(".ext_fun_attr"))); |
10 | void ext_fun(void) {} |
11 | #pragma clang section text="" |
12 | |
13 | void ext_fun2(void) __attribute__((section(".ext_fun2_attr"))); |
14 | #pragma clang section text=".ext_fun2_pragma" |
15 | void ext_fun2(void) {} |
16 | #pragma clang section text="" |
17 | |
18 | #pragma clang section text=".int_fun_pragma" |
19 | static void int_fun(void) __attribute__((section(".int_fun_attr"), used)); |
20 | static void int_fun(void) {} |
21 | #pragma clang section text="" |
22 | |
23 | static void int_fun2(void) __attribute__((section(".int_fun2_attr"), used)); |
24 | #pragma clang section text=".int_fun2_pragma" |
25 | static void int_fun2(void) {} |
26 | #pragma clang section text="" |
27 | |
28 | // Rodata tests. |
29 | #pragma clang section rodata=".ext_const_pragma" |
30 | __attribute__((section(".ext_const_attr"))) |
31 | const int ext_const = 1; |
32 | #pragma clang section rodata="" |
33 | |
34 | #pragma clang section rodata=".int_const_pragma" |
35 | __attribute__((section(".int_const_attr"), used)) |
36 | static const int int_const = 1; |
37 | #pragma clang section rodata="" |
38 | |
39 | // Data tests. |
40 | #pragma clang section data=".ext_var_pragma" |
41 | __attribute__((section(".ext_var_attr"))) |
42 | int ext_var = 1; |
43 | #pragma clang section data="" |
44 | |
45 | #pragma clang section data=".int_var_pragma" |
46 | __attribute__((section(".int_var_attr"), used)) |
47 | static int int_var = 1; |
48 | #pragma clang section data="" |
49 | |
50 | // Bss tests. |
51 | #pragma clang section bss=".ext_zvar_pragma" |
52 | __attribute__((section(".ext_zvar_attr"))) |
53 | int ext_zvar; |
54 | #pragma clang section bss="" |
55 | |
56 | #pragma clang section bss=".int_zvar_pragma" |
57 | __attribute__((section(".int_zvar_attr"), used)) |
58 | static int int_zvar; |
59 | #pragma clang section bss="" |
60 | |
61 | // CHECK: @ext_const = constant i32 1, section ".ext_const_attr", align 4{{$}} |
62 | // CHECK: @int_const = internal constant i32 1, section ".int_const_attr", align 4{{$}} |
63 | // CHECK: @ext_var = global i32 1, section ".ext_var_attr", align 4{{$}} |
64 | // CHECK: @int_var = internal global i32 1, section ".int_var_attr", align 4{{$}} |
65 | // CHECK: @ext_zvar = global i32 0, section ".ext_zvar_attr", align 4{{$}} |
66 | // CHECK: @int_zvar = internal global i32 0, section ".int_zvar_attr", align 4{{$}} |
67 | // CHECK: define void @ext_fun() #0 section ".ext_fun_attr" |
68 | // CHECK: define void @ext_fun2() #0 section ".ext_fun2_attr" |
69 | // CHECK: define internal void @int_fun() #0 section ".int_fun_attr" |
70 | // CHECK: define internal void @int_fun2() #0 section ".int_fun2_attr" |
71 | // |
72 | // Function attributes should not include implicit-section-name. |
73 | // CHECK-NOT: attributes #0 = {{.*}}implicit-section-name |
74 | // |
75 | // No other attribute group should be present in the file. |
76 | // CHECK-NOT: attributes #1 |
77 | |