| 1 |
// RUN: %clang_cc1 -triple thumbv7-apple-ios7.0 -target-abi apcs-gnu -std=c++11 -verify %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
struct true_type { |
| 5 |
static constexpr const bool value = true; |
| 6 |
}; |
| 7 |
|
| 8 |
struct false_type { |
| 9 |
static constexpr const bool value = false; |
| 10 |
}; |
| 11 |
|
| 12 |
template <class _Tp, class _Up> struct is_same : public false_type {}; |
| 13 |
template <class _Tp> struct is_same<_Tp, _Tp> : public true_type {}; |
| 14 |
|
| 15 |
// Check that our 'is_same' works. |
| 16 |
static_assert(is_same<char, char>::value, "is_same is broken"); |
| 17 |
static_assert(!is_same<char, char *>::value, "is_same is broken"); |
| 18 |
|
| 19 |
template <class _Tp, unsigned _AlignOf, unsigned _SizeOf> |
| 20 |
struct check_type { |
| 21 |
static constexpr const bool value = |
| 22 |
(alignof(_Tp) == _AlignOf) && (sizeof(_Tp) == _SizeOf); |
| 23 |
}; |
| 24 |
|
| 25 |
//===----------------------------------------------------------------------===// |
| 26 |
// Fundamental types |
| 27 |
//===----------------------------------------------------------------------===// |
| 28 |
|
| 29 |
static_assert(check_type<bool, 1, 1>::value, "bool is wrong"); |
| 30 |
|
| 31 |
static_assert(check_type<char, 1, 1>::value, "char is wrong"); |
| 32 |
static_assert(check_type<signed char, 1, 1>::value, "signed char is wrong"); |
| 33 |
static_assert(check_type<unsigned char, 1, 1>::value, "unsigned char is wrong"); |
| 34 |
|
| 35 |
static_assert(check_type<char16_t, 2, 2>::value, "char16_t is wrong"); |
| 36 |
static_assert(check_type<char32_t, 4, 4>::value, "char32_t is wrong"); |
| 37 |
static_assert(check_type<wchar_t, 4, 4>::value, "wchar_t is wrong"); |
| 38 |
|
| 39 |
static_assert(check_type<short, 2, 2>::value, "short is wrong"); |
| 40 |
static_assert(check_type<unsigned short, 2, 2>::value, "unsigned short is wrong"); |
| 41 |
|
| 42 |
static_assert(check_type<int, 4, 4>::value, "int is wrong"); |
| 43 |
static_assert(check_type<unsigned int, 4, 4>::value, "unsigned int is wrong"); |
| 44 |
|
| 45 |
static_assert(check_type<long, 4, 4>::value, "long is wrong"); |
| 46 |
static_assert(check_type<unsigned long, 4, 4>::value, "unsigned long is wrong"); |
| 47 |
|
| 48 |
static_assert(check_type<long long, 4, 8>::value, "long long is wrong"); |
| 49 |
static_assert(check_type<unsigned long long, 4, 8>::value, "unsigned long long is wrong"); |
| 50 |
|
| 51 |
static_assert(check_type<float, 4, 4>::value, "float is wrong"); |
| 52 |
static_assert(check_type<double, 4, 8>::value, "double is wrong"); |
| 53 |
static_assert(check_type<long double, 4, 8>::value, "long double is wrong"); |
| 54 |
|
| 55 |
static_assert(check_type<void *, 4, 4>::value, "'void *' is wrong"); |
| 56 |
static_assert(check_type<int (*)(int), 4, 4>::value, "function pointer is wrong"); |
| 57 |
|
| 58 |
//===----------------------------------------------------------------------===// |
| 59 |
// stdarg.h |
| 60 |
//===----------------------------------------------------------------------===// |
| 61 |
|
| 62 |
#include <stdarg.h> |
| 63 |
|
| 64 |
static_assert(check_type<va_list, 4, 4>::value, "va_list is wrong"); |
| 65 |
|
| 66 |
//===----------------------------------------------------------------------===// |
| 67 |
// stddef.h |
| 68 |
//===----------------------------------------------------------------------===// |
| 69 |
|
| 70 |
#define __STDC_WANT_LIB_EXT1__ 1 |
| 71 |
#include <stddef.h> |
| 72 |
|
| 73 |
static_assert(is_same<int, ::ptrdiff_t>::value, "::ptrdiff_t is wrong"); |
| 74 |
static_assert(is_same<decltype(sizeof(char)), ::size_t>::value, "::size_t is wrong"); |
| 75 |
static_assert(is_same<long unsigned int, ::size_t>::value, "::size_t is wrong"); |
| 76 |
static_assert(is_same<long unsigned int, ::rsize_t>::value, "::rsize_t is wrong"); |
| 77 |
static_assert(is_same<long double, ::max_align_t>::value, "::max_align_t is wrong"); |
| 78 |
|
| 79 |
#define __need_wint_t |
| 80 |
#include <stddef.h> |
| 81 |
|
| 82 |
static_assert(is_same<int, ::wint_t>::value, "::wint_t is wrong"); |
| 83 |
|