[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / clang-sections-tentative.c
blob379b0c068b11f0f0bed61893280c2261d387b332
1 // RUN: %clang_cc1 -x c -emit-llvm -triple arm-none-eabi -o - %s | FileCheck %s
3 // Test that section attributes are attached to C tentative definitions as per
4 // '#pragma clang section' directives.
6 #pragma clang section bss = ".bss.1"
7 int x; // bss.1
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
14 #pragma clang section bss = ".bss.2"
15 int x; // stays in .bss.1
16 int y; // .bss.2
18 // Test the same for `const` declarations.
19 #pragma clang section rodata = ".rodata.1"
20 const int cx; // rodata.1
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
27 #pragma clang section rodata = ".rodata.2"
28 const int cx; // stays in .rodata.1
29 const int cy; // .rodata.2
31 // CHECK: @x ={{.*}} global i32 0, align 4 #0
32 // CHECK: @y ={{.*}} global i32 0, align 4 #1
33 // CHECK: @z ={{.*}} 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
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" }