1 // RUN: %clang_cc1 -emit-llvm -triple arm-none-eabi -o - %s | FileCheck %s
3 // Test interaction between __attribute__((section())) and '#pragma clang
4 // section' directives. The attribute should always have higher priority than
8 #pragma clang section text=".ext_fun_pragma"
9 void ext_fun(void) __attribute__((section(".ext_fun_attr")));
11 #pragma clang section text=""
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=""
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=""
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=""
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=""
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=""
40 #pragma clang section data=".ext_var_pragma"
41 __attribute__((section(".ext_var_attr")))
43 #pragma clang section data=""
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=""
51 #pragma clang section bss=".ext_zvar_pragma"
52 __attribute__((section(".ext_zvar_attr")))
54 #pragma clang section bss=""
56 #pragma clang section bss=".int_zvar_pragma"
57 __attribute__((section(".int_zvar_attr"), used
))
59 #pragma clang section bss=""
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"
72 // No other attribute group should be present in the file.
73 // CHECK-NOT: attributes #1