1 // RUN: %clang -target wasm32-unknown-unknown -### %s -emit-llvm-only -c 2>&1 \ 2 // RUN: | FileCheck %s -check-prefix=ECHO 3 // RUN: %clang -target wasm32-unknown-unknown %s -emit-llvm -S -o - \ 4 // RUN: | FileCheck %s 5 // RUN: %clang -target wasm32-unknown-unknown %s -emit-llvm -S -pthread -o - \ 6 // RUN: | FileCheck %s -check-prefix=THREADS 7 8 // ECHO: {{.*}} "-cc1" {{.*}}wasm32-unknown-unknown.c 9 10 typedef __builtin_va_list va_list; 11 typedef __SIZE_TYPE__ size_t; 12 typedef __PTRDIFF_TYPE__ ptrdiff_t; 13 14 extern "C" { 15 16 // CHECK: @align_c = global i32 1 17 int align_c = __alignof(char); 18 19 // CHECK: @align_s = global i32 2 20 int align_s = __alignof(short); 21 22 // CHECK: @align_i = global i32 4 23 int align_i = __alignof(int); 24 25 // CHECK: @align_l = global i32 4 26 int align_l = __alignof(long); 27 28 // CHECK: @align_ll = global i32 8 29 int align_ll = __alignof(long long); 30 31 // CHECK: @align_p = global i32 4 32 int align_p = __alignof(void*); 33 34 // CHECK: @align_f = global i32 4 35 int align_f = __alignof(float); 36 37 // CHECK: @align_d = global i32 8 38 int align_d = __alignof(double); 39 40 // CHECK: @align_ld = global i32 16 41 int align_ld = __alignof(long double); 42 43 // CHECK: @align_vl = global i32 4 44 int align_vl = __alignof(va_list); 45 46 // CHECK: _GNU_SOURCEdefined 47 #ifdef _GNU_SOURCE _GNU_SOURCEdefined()48void _GNU_SOURCEdefined() {} 49 #endif 50 51 // THREADS: _REENTRANTdefined 52 // CHECK: _REENTRANTundefined 53 #ifdef _REENTRANT _REENTRANTdefined()54void _REENTRANTdefined() {} 55 #else _REENTRANTundefined()56void _REENTRANTundefined() {} 57 #endif 58 59 // Check types 60 61 // CHECK: signext i8 @check_char() check_char()62char check_char() { return 0; } 63 64 // CHECK: signext i16 @check_short() check_short()65short check_short() { return 0; } 66 67 // CHECK: i32 @check_int() check_int()68int check_int() { return 0; } 69 70 // CHECK: i32 @check_long() check_long()71long check_long() { return 0; } 72 73 // CHECK: i64 @check_longlong() check_longlong()74long long check_longlong() { return 0; } 75 76 // CHECK: zeroext i8 @check_uchar() check_uchar()77unsigned char check_uchar() { return 0; } 78 79 // CHECK: zeroext i16 @check_ushort() check_ushort()80unsigned short check_ushort() { return 0; } 81 82 // CHECK: i32 @check_uint() check_uint()83unsigned int check_uint() { return 0; } 84 85 // CHECK: i32 @check_ulong() check_ulong()86unsigned long check_ulong() { return 0; } 87 88 // CHECK: i64 @check_ulonglong() check_ulonglong()89unsigned long long check_ulonglong() { return 0; } 90 91 // CHECK: i32 @check_size_t() check_size_t()92size_t check_size_t() { return 0; } 93 94 // CHECK: float @check_float() check_float()95float check_float() { return 0; } 96 97 // CHECK: double @check_double() check_double()98double check_double() { return 0; } 99 100 // CHECK: fp128 @check_longdouble() check_longdouble()101long double check_longdouble() { return 0; } 102 103 } 104 105 template<int> void Switch(); 106 template<> void Switch<4>(); 107 template<> void Switch<8>(); 108 template<> void Switch<16>(); 109 check_pointer_size()110void check_pointer_size() { 111 // CHECK: SwitchILi4 112 Switch<sizeof(void*)>(); 113 114 // CHECK: SwitchILi8 115 Switch<sizeof(long long)>(); 116 117 // CHECK: SwitchILi4 118 Switch<sizeof(va_list)>(); 119 } 120