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