Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / C / C2x / n3035.c
blob417cf2d4b880f557b6babaa5afc4032a374e8e74
1 // RUN: %clang_cc1 -triple x86_64 -ffreestanding -verify -std=c2x %s
3 /* WG14 N3035: yes
4 * _BitInt Fixes
5 */
7 #include <stdint.h>
9 /* intmax_t and uintmax_t don't need to be able to represent all of the values
10 * of a bit-precise integer type. We test this by using a bit-precise integer
11 * suffix on some huge values used within the preprocessor.
13 #if 0x1'FFFF'FFFF'FFFF'FFFFwb == 0 /* expected-error {{integer literal is too large to be represented in any integer type}} */
14 #endif
16 /* Yet we can use that value as an initializer... */
17 _BitInt(66) Val = 0x1'FFFF'FFFF'FFFF'FFFFwb;
19 /* ...so long as the type is wide enough. */
20 intmax_t WrongVal = 0x1'FFFF'FFFF'FFFF'FFFFwb; /* expected-warning-re {{implicit conversion from '_BitInt(66)' to 'intmax_t' (aka '{{.*}}') changes value from 36893488147419103231 to -1}} */
22 /* None of the types in stdint.h may be defined in terms of a bit-precise
23 * integer type. This macro presumes that if the type is not one of the builtin
24 * scalar integer types, the type must be a bit-precise type. We're using this
25 * because C does not have a particularly straightforward way to use _Generic
26 * with arbitrary bit-precise integer types.
28 #define IS_NOT_BIT_PRECISE(TYPE) _Generic((TYPE){ 0 }, \
29 short : 1, int : 1, long : 1, long long : 1, \
30 unsigned short : 1, unsigned int : 1, \
31 unsigned long : 1, unsigned long long : 1, \
32 char : 1, signed char : 1, unsigned char : 1,\
33 default : 0)
34 static_assert(IS_NOT_BIT_PRECISE(int8_t));
35 static_assert(IS_NOT_BIT_PRECISE(uint8_t));
36 static_assert(IS_NOT_BIT_PRECISE(int16_t));
37 static_assert(IS_NOT_BIT_PRECISE(uint16_t));
38 static_assert(IS_NOT_BIT_PRECISE(int32_t));
39 static_assert(IS_NOT_BIT_PRECISE(uint32_t));
40 static_assert(IS_NOT_BIT_PRECISE(int64_t));
41 static_assert(IS_NOT_BIT_PRECISE(uint64_t));
42 static_assert(IS_NOT_BIT_PRECISE(intmax_t));
43 static_assert(IS_NOT_BIT_PRECISE(uintmax_t));
44 static_assert(IS_NOT_BIT_PRECISE(intptr_t));
45 static_assert(IS_NOT_BIT_PRECISE(uintptr_t));
47 /* FIXME: N3035 also added wording disallowing using a bit-precise integer type
48 * as the compatible type for an enumerated type. However, we don't have a
49 * direct way to test that, so we're claiming conformance without test
50 * coverage.