1 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s
5 #pragma const_seg(".my_const")
6 #pragma bss_seg(".my_bss")
8 #pragma data_seg(".data")
10 #pragma data_seg(push, label, ".data2")
13 const char* s = "my string!";
14 #pragma data_seg(push, ".my_seg")
16 #pragma data_seg(pop, label)
22 #pragma code_seg(".my_code")
26 #pragma bss_seg(".bss1")
27 #pragma bss_seg(push, test, ".bss2")
34 #pragma section("read_flag_section", read)
35 // Even though they are not declared const, these become constant since they are
36 // in a read-only section.
37 __declspec(allocate("read_flag_section")) int unreferenced = 0;
38 extern __declspec(allocate("read_flag_section")) int referenced = 42;
39 int *user() { return &referenced; }
41 #pragma section("no_section_attributes")
42 // A pragma section with no section attributes is read/write.
43 __declspec(allocate("no_section_attributes")) int implicitly_read_write = 42;
45 #pragma section("long_section", long)
46 // Pragma section ignores "long".
47 __declspec(allocate("long_section")) long long_var = 42;
49 #pragma section("short_section", short)
50 // Pragma section ignores "short".
51 __declspec(allocate("short_section")) short short_var = 42;
54 //CHECK: @D = global i32 1
55 //CHECK: @a = global i32 1, section ".data"
56 //CHECK: @b = constant i32 1, section ".my_const"
57 //CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my string!\00"
58 //CHECK: @s = global i8* getelementptr inbounds ([11 x i8], [11 x i8]* @[[MYSTR]], i32 0, i32 0), section ".data2"
59 //CHECK: @c = global i32 1, section ".my_seg"
60 //CHECK: @d = global i32 1, section ".data"
61 //CHECK: @e = global i32 0, section ".my_bss"
62 //CHECK: @f = global i32 0, section ".c"
63 //CHECK: @i = global i32 0
64 //CHECK: @TEST1 = global i32 0
65 //CHECK: @TEST2 = global i32 0, section ".bss1"
66 //CHECK: @unreferenced = constant i32 0, section "read_flag_section"
67 //CHECK: @referenced = constant i32 42, section "read_flag_section"
68 //CHECK: @implicitly_read_write = global i32 42, section "no_section_attributes"
69 //CHECK: @long_var = global i32 42, section "long_section"
70 //CHECK: @short_var = global i16 42, section "short_section"
71 //CHECK: define void @g()
72 //CHECK: define void @h() {{.*}} section ".my_code"