2013-07-23 23:57:21 +08:00
|
|
|
// RUN: %clang -target le32-unknown-nacl -### %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
|
2012-10-10 04:46:28 +08:00
|
|
|
// RUN: %clang -target le32-unknown-nacl %s -emit-llvm -S -c -o - | FileCheck %s
|
|
|
|
// RUN: %clang -target le32-unknown-nacl %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS
|
2011-08-25 04:22:22 +08:00
|
|
|
|
2013-07-23 23:57:21 +08:00
|
|
|
// ECHO: {{.*}} "-cc1" {{.*}}le32-unknown-nacl.c
|
2011-08-25 04:22:22 +08:00
|
|
|
|
2014-09-15 07:42:15 +08:00
|
|
|
typedef __builtin_va_list va_list;
|
|
|
|
typedef __SIZE_TYPE__ size_t;
|
|
|
|
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
2011-08-25 04:22:22 +08:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_c = dso_local global i32 1
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_c = __alignof(char);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_s = dso_local global i32 2
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_s = __alignof(short);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_i = dso_local global i32 4
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_i = __alignof(int);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_l = dso_local global i32 4
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_l = __alignof(long);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_ll = dso_local global i32 8
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_ll = __alignof(long long);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_p = dso_local global i32 4
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_p = __alignof(void*);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_f = dso_local global i32 4
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_f = __alignof(float);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_d = dso_local global i32 8
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_d = __alignof(double);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_ld = dso_local global i32 8
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_ld = __alignof(long double);
|
|
|
|
|
2018-02-08 06:15:33 +08:00
|
|
|
// CHECK: @align_vl = dso_local global i32 4
|
2011-08-30 06:39:12 +08:00
|
|
|
int align_vl = __alignof(va_list);
|
|
|
|
|
2012-03-29 08:05:59 +08:00
|
|
|
// CHECK: __LITTLE_ENDIAN__defined
|
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
void __LITTLE_ENDIAN__defined() {}
|
|
|
|
#endif
|
|
|
|
|
2011-08-30 06:39:12 +08:00
|
|
|
// CHECK: __native_client__defined
|
2011-08-25 04:22:22 +08:00
|
|
|
#ifdef __native_client__
|
2011-08-30 06:39:12 +08:00
|
|
|
void __native_client__defined() {}
|
2011-08-25 04:22:22 +08:00
|
|
|
#endif
|
|
|
|
|
2011-08-30 06:39:12 +08:00
|
|
|
// CHECK: __le32__defined
|
2011-08-25 04:22:22 +08:00
|
|
|
#ifdef __le32__
|
2011-08-30 06:39:12 +08:00
|
|
|
void __le32__defined() {}
|
2011-08-25 04:22:22 +08:00
|
|
|
#endif
|
|
|
|
|
2011-08-30 06:39:12 +08:00
|
|
|
// CHECK: __pnacl__defined
|
2011-08-25 04:22:22 +08:00
|
|
|
#ifdef __pnacl__
|
2011-08-30 06:39:12 +08:00
|
|
|
void __pnacl__defined() {}
|
2011-08-25 04:22:22 +08:00
|
|
|
#endif
|
|
|
|
|
2017-02-08 03:00:06 +08:00
|
|
|
// CHECK: unixdefined
|
|
|
|
#ifdef unix
|
|
|
|
void unixdefined() {}
|
2011-08-26 07:49:20 +08:00
|
|
|
#endif
|
|
|
|
|
2011-08-30 06:39:12 +08:00
|
|
|
// CHECK: __ELF__defined
|
2011-08-26 07:49:20 +08:00
|
|
|
#ifdef __ELF__
|
2011-08-30 06:39:12 +08:00
|
|
|
void __ELF__defined() {}
|
2011-08-26 07:49:20 +08:00
|
|
|
#endif
|
|
|
|
|
2011-08-30 06:39:12 +08:00
|
|
|
// CHECK: _GNU_SOURCEdefined
|
2011-08-26 07:49:20 +08:00
|
|
|
#ifdef _GNU_SOURCE
|
2011-08-30 06:39:12 +08:00
|
|
|
void _GNU_SOURCEdefined() {}
|
2011-08-26 07:49:20 +08:00
|
|
|
#endif
|
|
|
|
|
2011-08-30 06:39:12 +08:00
|
|
|
// THREADS: _REENTRANTdefined
|
|
|
|
// CHECK: _REENTRANTundefined
|
|
|
|
#ifdef _REENTRANT
|
|
|
|
void _REENTRANTdefined() {}
|
|
|
|
#else
|
|
|
|
void _REENTRANTundefined() {}
|
|
|
|
#endif
|
2011-08-26 07:49:20 +08:00
|
|
|
|
2011-08-25 04:22:22 +08:00
|
|
|
// Check types
|
|
|
|
|
|
|
|
// CHECK: signext i8 @check_char()
|
|
|
|
char check_char() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: signext i16 @check_short()
|
|
|
|
short check_short() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i32 @check_int()
|
|
|
|
int check_int() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i32 @check_long()
|
|
|
|
long check_long() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i64 @check_longlong()
|
|
|
|
long long check_longlong() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: zeroext i8 @check_uchar()
|
|
|
|
unsigned char check_uchar() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: zeroext i16 @check_ushort()
|
|
|
|
unsigned short check_ushort() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i32 @check_uint()
|
|
|
|
unsigned int check_uint() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i32 @check_ulong()
|
|
|
|
unsigned long check_ulong() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i64 @check_ulonglong()
|
|
|
|
unsigned long long check_ulonglong() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: i32 @check_size_t()
|
|
|
|
size_t check_size_t() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: float @check_float()
|
|
|
|
float check_float() { return 0; }
|
|
|
|
|
|
|
|
// CHECK: double @check_double()
|
|
|
|
double check_double() { return 0; }
|
|
|
|
|
2011-08-25 05:22:25 +08:00
|
|
|
// CHECK: double @check_longdouble()
|
|
|
|
long double check_longdouble() { return 0; }
|
|
|
|
|
2011-08-25 04:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<int> void Switch();
|
|
|
|
template<> void Switch<4>();
|
|
|
|
template<> void Switch<8>();
|
2011-08-25 05:22:25 +08:00
|
|
|
template<> void Switch<16>();
|
2011-08-25 04:22:22 +08:00
|
|
|
|
|
|
|
void check_pointer_size() {
|
|
|
|
// CHECK: SwitchILi4
|
|
|
|
Switch<sizeof(void*)>();
|
|
|
|
|
|
|
|
// CHECK: SwitchILi8
|
|
|
|
Switch<sizeof(long long)>();
|
2011-08-25 05:22:25 +08:00
|
|
|
|
|
|
|
// CHECK: SwitchILi16
|
|
|
|
Switch<sizeof(va_list)>();
|
2011-08-25 04:22:22 +08:00
|
|
|
}
|