1 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s 2 3 extern "C" { 4 5 #pragma const_seg(".my_const") 6 #pragma bss_seg(".my_bss") 7 int D = 1; 8 #pragma data_seg(".data") 9 int a = 1; 10 #pragma data_seg(push, label, ".data2") 11 extern const int b; 12 const int b = 1; 13 const char* s = "my string!"; 14 #pragma data_seg(push, ".my_seg") 15 int c = 1; 16 #pragma data_seg(pop, label) 17 int d = 1; 18 int e; 19 #pragma bss_seg(".c") 20 int f; 21 void g(void){} 22 #pragma code_seg(".my_code") 23 void h(void){} 24 #pragma bss_seg() 25 int i; 26 #pragma bss_seg(".bss1") 27 #pragma bss_seg(push, test, ".bss2") 28 #pragma bss_seg() 29 #pragma bss_seg() 30 int TEST1; 31 #pragma bss_seg(pop) 32 int TEST2; 33 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; } 40 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; 44 45 #pragma section("long_section", long) 46 // Pragma section ignores "long". 47 __declspec(allocate("long_section")) long long_var = 42; 48 49 #pragma section("short_section", short) 50 // Pragma section ignores "short". 51 __declspec(allocate("short_section")) short short_var = 42; 52 } 53 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]* @[[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" 73