1 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o - %s | FileCheck %s
8 extern const Mutable mutable_default_section
;
9 const Mutable mutable_default_section
;
13 extern const Normal normal_default_section
;
14 const Normal normal_default_section
;
15 #pragma const_seg(".my_const")
16 #pragma bss_seg(".my_bss")
18 #pragma data_seg(".data")
20 extern const Mutable mutable_custom_section
;
21 const Mutable mutable_custom_section
; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'mutable_custom_section' due to the presence of a mutable field}}
22 extern const Normal normal_custom_section
;
23 const Normal normal_custom_section
;
24 struct NonTrivialDtor
{
27 extern const NonTrivialDtor non_trivial_dtor_custom_section
;
28 const NonTrivialDtor non_trivial_dtor_custom_section
; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'non_trivial_dtor_custom_section' due to the presence of a non-trivial destructor}}
29 struct NonTrivialCtor
{
32 extern const NonTrivialCtor non_trivial_ctor_custom_section
;
33 const NonTrivialCtor non_trivial_ctor_custom_section
; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'non_trivial_ctor_custom_section' due to the presence of a non-trivial constructor}}
34 #pragma data_seg(push, label, ".data2")
37 const char* s
= "my string!";
38 #pragma data_seg(push, ".my_seg")
40 #pragma data_seg(pop, label)
46 #pragma code_seg(".my_code")
50 #pragma bss_seg(".bss1")
51 #pragma bss_seg(push, test, ".bss2")
59 // Check "save-restore" of pragma stacks.
62 #pragma bss_seg(push, ".bss3")
63 #pragma code_seg(push, ".my_code1")
64 #pragma const_seg(push, ".my_const1")
65 #pragma data_seg(push, ".data3")
68 #pragma bss_seg(push, ".bss4")
69 #pragma code_seg(push, ".my_code2")
70 #pragma const_seg(push, ".my_const2")
71 #pragma data_seg(push, ".data4")
77 void h2(void) {} // should be in ".my_code"
78 int TEST3
; // should be in ".bss1"
79 int d2
= 1; // should be in ".data"
80 extern const int b2
; // should be in ".my_const"
83 #pragma section("read_flag_section", read)
84 // Even though they are not declared const, these become constant since they are
85 // in a read-only section.
86 __declspec(allocate("read_flag_section")) int unreferenced
= 0;
87 extern __declspec(allocate("read_flag_section")) int referenced
= 42;
88 int *user() { return &referenced
; }
90 #pragma section("no_section_attributes")
91 // A pragma section with no section attributes is read/write.
92 __declspec(allocate("no_section_attributes")) int implicitly_read_write
= 42;
94 #pragma section("long_section", long)
95 // Pragma section ignores "long".
96 __declspec(allocate("long_section")) long long_var
= 42;
98 #pragma section("short_section", short)
99 // Pragma section ignores "short".
100 __declspec(allocate("short_section")) short short_var
= 42;
103 extern const t2 non_trivial_ctor
;
104 __declspec(allocate("non_trivial_ctor_section")) const t2 non_trivial_ctor_var
;
108 //CHECK: @mutable_default_section = dso_local global %struct.Mutable { i32 3 }, align 4{{$}}
109 //CHECK: @normal_default_section = dso_local constant %struct.Normal { i32 2 }, align 4{{$}}
110 //CHECK: @D = dso_local global i32 1
111 //CHECK: @a = dso_local global i32 1, section ".data"
112 //CHECK: @mutable_custom_section = dso_local global %struct.Mutable { i32 3 }, section ".data", align 4
113 //CHECK: @normal_custom_section = dso_local constant %struct.Normal { i32 2 }, section ".my_const", align 4
114 //CHECK: @b = dso_local constant i32 1, section ".my_const"
115 //CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my string!\00"
116 //CHECK: @s = dso_local global ptr @[[MYSTR]], section ".data2"
117 //CHECK: @c = dso_local global i32 1, section ".my_seg"
118 //CHECK: @d = dso_local global i32 1, section ".data"
119 //CHECK: @e = dso_local global i32 0, section ".my_bss"
120 //CHECK: @f = dso_local global i32 0, section ".c"
121 //CHECK: @i = dso_local global i32 0
122 //CHECK: @TEST1 = dso_local global i32 0
123 //CHECK: @TEST2 = dso_local global i32 0, section ".bss1"
124 //CHECK: @TEST3 = dso_local global i32 0, section ".bss1"
125 //CHECK: @d2 = dso_local global i32 1, section ".data"
126 //CHECK: @b2 = dso_local constant i32 1, section ".my_const"
127 //CHECK: @unreferenced = dso_local constant i32 0, section "read_flag_section"
128 //CHECK: @referenced = dso_local constant i32 42, section "read_flag_section"
129 //CHECK: @implicitly_read_write = dso_local global i32 42, section "no_section_attributes"
130 //CHECK: @long_var = dso_local global i32 42, section "long_section"
131 //CHECK: @short_var = dso_local global i16 42, section "short_section"
132 //CHECK: @non_trivial_ctor_var = internal global %struct.t2 zeroinitializer, section "non_trivial_ctor_section"
133 //CHECK: define dso_local void @g()
134 //CHECK: define dso_local void @h() {{.*}} section ".my_code"
135 //CHECK: define dso_local void @h2() {{.*}} section ".my_code"