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