1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test <stdint.h>
#include <stdint.h>
#include <csignal>
#include <cwctype>
#include <climits>
#include <type_traits>
#include <limits>
#include <cassert>
int main()
{
// typedef int8_t
static_assert(sizeof(int8_t)*CHAR_BIT == 8,
"sizeof(int8_t)*CHAR_BIT == 8");
static_assert(std::is_signed<int8_t>::value,
"std::is_signed<int8_t>::value");
// typedef int16_t
static_assert(sizeof(int16_t)*CHAR_BIT == 16,
"sizeof(int16_t)*CHAR_BIT == 16");
static_assert(std::is_signed<int16_t>::value,
"std::is_signed<int16_t>::value");
// typedef int32_t
static_assert(sizeof(int32_t)*CHAR_BIT == 32,
"sizeof(int32_t)*CHAR_BIT == 32");
static_assert(std::is_signed<int32_t>::value,
"std::is_signed<int32_t>::value");
// typedef int64_t
static_assert(sizeof(int64_t)*CHAR_BIT == 64,
"sizeof(int64_t)*CHAR_BIT == 64");
static_assert(std::is_signed<int64_t>::value,
"std::is_signed<int64_t>::value");
// typedef uint8_t
static_assert(sizeof(uint8_t)*CHAR_BIT == 8,
"sizeof(uint8_t)*CHAR_BIT == 8");
static_assert(std::is_unsigned<uint8_t>::value,
"std::is_unsigned<uint8_t>::value");
// typedef uint16_t
static_assert(sizeof(uint16_t)*CHAR_BIT == 16,
"sizeof(uint16_t)*CHAR_BIT == 16");
static_assert(std::is_unsigned<uint16_t>::value,
"std::is_unsigned<uint16_t>::value");
// typedef uint32_t
static_assert(sizeof(uint32_t)*CHAR_BIT == 32,
"sizeof(uint32_t)*CHAR_BIT == 32");
static_assert(std::is_unsigned<uint32_t>::value,
"std::is_unsigned<uint32_t>::value");
// typedef uint64_t
static_assert(sizeof(uint64_t)*CHAR_BIT == 64,
"sizeof(uint64_t)*CHAR_BIT == 64");
static_assert(std::is_unsigned<uint64_t>::value,
"std::is_unsigned<uint64_t>::value");
// typedef int_least8_t
static_assert(sizeof(int_least8_t)*CHAR_BIT >= 8,
"sizeof(int_least8_t)*CHAR_BIT >= 8");
static_assert(std::is_signed<int_least8_t>::value,
"std::is_signed<int_least8_t>::value");
// typedef int_least16_t
static_assert(sizeof(int_least16_t)*CHAR_BIT >= 16,
"sizeof(int_least16_t)*CHAR_BIT >= 16");
static_assert(std::is_signed<int_least16_t>::value,
"std::is_signed<int_least16_t>::value");
// typedef int_least32_t
static_assert(sizeof(int_least32_t)*CHAR_BIT >= 32,
"sizeof(int_least32_t)*CHAR_BIT >= 32");
static_assert(std::is_signed<int_least32_t>::value,
"std::is_signed<int_least32_t>::value");
// typedef int_least64_t
static_assert(sizeof(int_least64_t)*CHAR_BIT >= 64,
"sizeof(int_least64_t)*CHAR_BIT >= 64");
static_assert(std::is_signed<int_least64_t>::value,
"std::is_signed<int_least64_t>::value");
// typedef uint_least8_t
static_assert(sizeof(uint_least8_t)*CHAR_BIT >= 8,
"sizeof(uint_least8_t)*CHAR_BIT >= 8");
static_assert(std::is_unsigned<uint_least8_t>::value,
"std::is_unsigned<uint_least8_t>::value");
// typedef uint_least16_t
static_assert(sizeof(uint_least16_t)*CHAR_BIT >= 16,
"sizeof(uint_least16_t)*CHAR_BIT >= 16");
static_assert(std::is_unsigned<uint_least16_t>::value,
"std::is_unsigned<uint_least16_t>::value");
// typedef uint_least32_t
static_assert(sizeof(uint_least32_t)*CHAR_BIT >= 32,
"sizeof(uint_least32_t)*CHAR_BIT >= 32");
static_assert(std::is_unsigned<uint_least32_t>::value,
"std::is_unsigned<uint_least32_t>::value");
// typedef uint_least64_t
static_assert(sizeof(uint_least64_t)*CHAR_BIT >= 64,
"sizeof(uint_least64_t)*CHAR_BIT >= 64");
static_assert(std::is_unsigned<uint_least64_t>::value,
"std::is_unsigned<uint_least64_t>::value");
// typedef int_fast8_t
static_assert(sizeof(int_fast8_t)*CHAR_BIT >= 8,
"sizeof(int_fast8_t)*CHAR_BIT >= 8");
static_assert(std::is_signed<int_fast8_t>::value,
"std::is_signed<int_fast8_t>::value");
// typedef int_fast16_t
static_assert(sizeof(int_fast16_t)*CHAR_BIT >= 16,
"sizeof(int_fast16_t)*CHAR_BIT >= 16");
static_assert(std::is_signed<int_fast16_t>::value,
"std::is_signed<int_fast16_t>::value");
// typedef int_fast32_t
static_assert(sizeof(int_fast32_t)*CHAR_BIT >= 32,
"sizeof(int_fast32_t)*CHAR_BIT >= 32");
static_assert(std::is_signed<int_fast32_t>::value,
"std::is_signed<int_fast32_t>::value");
// typedef int_fast64_t
static_assert(sizeof(int_fast64_t)*CHAR_BIT >= 64,
"sizeof(int_fast64_t)*CHAR_BIT >= 64");
static_assert(std::is_signed<int_fast64_t>::value,
"std::is_signed<int_fast64_t>::value");
// typedef uint_fast8_t
static_assert(sizeof(uint_fast8_t)*CHAR_BIT >= 8,
"sizeof(uint_fast8_t)*CHAR_BIT >= 8");
static_assert(std::is_unsigned<uint_fast8_t>::value,
"std::is_unsigned<uint_fast8_t>::value");
// typedef uint_fast16_t
static_assert(sizeof(uint_fast16_t)*CHAR_BIT >= 16,
"sizeof(uint_fast16_t)*CHAR_BIT >= 16");
static_assert(std::is_unsigned<uint_fast16_t>::value,
"std::is_unsigned<uint_fast16_t>::value");
// typedef uint_fast32_t
static_assert(sizeof(uint_fast32_t)*CHAR_BIT >= 32,
"sizeof(uint_fast32_t)*CHAR_BIT >= 32");
static_assert(std::is_unsigned<uint_fast32_t>::value,
"std::is_unsigned<uint_fast32_t>::value");
// typedef uint_fast64_t
static_assert(sizeof(uint_fast64_t)*CHAR_BIT >= 64,
"sizeof(uint_fast64_t)*CHAR_BIT >= 64");
static_assert(std::is_unsigned<uint_fast64_t>::value,
"std::is_unsigned<uint_fast64_t>::value");
// typedef intptr_t
static_assert(sizeof(intptr_t) >= sizeof(void*),
"sizeof(intptr_t) >= sizeof(void*)");
static_assert(std::is_signed<intptr_t>::value,
"std::is_signed<intptr_t>::value");
// typedef uintptr_t
static_assert(sizeof(uintptr_t) >= sizeof(void*),
"sizeof(uintptr_t) >= sizeof(void*)");
static_assert(std::is_unsigned<uintptr_t>::value,
"std::is_unsigned<uintptr_t>::value");
// typedef intmax_t
static_assert(sizeof(intmax_t) >= sizeof(long long),
"sizeof(intmax_t) >= sizeof(long long)");
static_assert(std::is_signed<intmax_t>::value,
"std::is_signed<intmax_t>::value");
// typedef uintmax_t
static_assert(sizeof(uintmax_t) >= sizeof(unsigned long long),
"sizeof(uintmax_t) >= sizeof(unsigned long long)");
static_assert(std::is_unsigned<uintmax_t>::value,
"std::is_unsigned<uintmax_t>::value");
// INTN_MIN
static_assert(INT8_MIN == -128, "INT8_MIN == -128");
static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
// INTN_MAX
static_assert(INT8_MAX == 127, "INT8_MAX == 127");
static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
// UINTN_MAX
static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
// INT_FASTN_MIN
static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
// INT_FASTN_MAX
static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
// UINT_FASTN_MAX
static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
// INTPTR_MIN
assert(INTPTR_MIN == std::numeric_limits<intptr_t>::min());
// INTPTR_MAX
assert(INTPTR_MAX == std::numeric_limits<intptr_t>::max());
// UINTPTR_MAX
assert(UINTPTR_MAX == std::numeric_limits<uintptr_t>::max());
// INTMAX_MIN
assert(INTMAX_MIN == std::numeric_limits<intmax_t>::min());
// INTMAX_MAX
assert(INTMAX_MAX == std::numeric_limits<intmax_t>::max());
// UINTMAX_MAX
assert(UINTMAX_MAX == std::numeric_limits<uintmax_t>::max());
// PTRDIFF_MIN
assert(PTRDIFF_MIN == std::numeric_limits<ptrdiff_t>::min());
// PTRDIFF_MAX
assert(PTRDIFF_MAX == std::numeric_limits<ptrdiff_t>::max());
// SIG_ATOMIC_MIN
assert(SIG_ATOMIC_MIN == std::numeric_limits<sig_atomic_t>::min());
// SIG_ATOMIC_MAX
assert(SIG_ATOMIC_MAX == std::numeric_limits<sig_atomic_t>::max());
// SIZE_MAX
assert(SIZE_MAX == std::numeric_limits<size_t>::max());
// WCHAR_MIN
assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
// WCHAR_MAX
assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
// WINT_MIN
assert(WINT_MIN == std::numeric_limits<wint_t>::min());
// WINT_MAX
assert(WINT_MAX == std::numeric_limits<wint_t>::max());
#ifndef INT8_C
#error INT8_C not defined
#endif
#ifndef INT16_C
#error INT16_C not defined
#endif
#ifndef INT32_C
#error INT32_C not defined
#endif
#ifndef INT64_C
#error INT64_C not defined
#endif
#ifndef UINT8_C
#error UINT8_C not defined
#endif
#ifndef UINT16_C
#error UINT16_C not defined
#endif
#ifndef UINT32_C
#error UINT32_C not defined
#endif
#ifndef UINT64_C
#error UINT64_C not defined
#endif
#ifndef INTMAX_C
#error INTMAX_C not defined
#endif
#ifndef UINTMAX_C
#error UINTMAX_C not defined
#endif
}
|