Files
TheRock/compiler/amd-llvm/clang/test/C/C23/n3035.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

52 lines
2.4 KiB
C

// RUN: %clang_cc1 -triple x86_64 -ffreestanding -verify -std=c2x %s
/* WG14 N3035: yes
* _BitInt Fixes
*/
#include <stdint.h>
/* intmax_t and uintmax_t don't need to be able to represent all of the values
* of a bit-precise integer type. We test this by using a bit-precise integer
* suffix on some huge values used within the preprocessor.
*/
#if 0x1'FFFF'FFFF'FFFF'FFFFwb == 0 /* expected-error {{integer literal is too large to be represented in any integer type}} */
#endif
/* Yet we can use that value as an initializer... */
_BitInt(66) Val = 0x1'FFFF'FFFF'FFFF'FFFFwb;
/* ...so long as the type is wide enough. */
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}} */
/* None of the types in stdint.h may be defined in terms of a bit-precise
* integer type. This macro presumes that if the type is not one of the builtin
* scalar integer types, the type must be a bit-precise type. We're using this
* because C does not have a particularly straightforward way to use _Generic
* with arbitrary bit-precise integer types.
*/
#define IS_NOT_BIT_PRECISE(TYPE) _Generic((TYPE){ 0 }, \
short : 1, int : 1, long : 1, long long : 1, \
unsigned short : 1, unsigned int : 1, \
unsigned long : 1, unsigned long long : 1, \
char : 1, signed char : 1, unsigned char : 1,\
default : 0)
static_assert(IS_NOT_BIT_PRECISE(int8_t));
static_assert(IS_NOT_BIT_PRECISE(uint8_t));
static_assert(IS_NOT_BIT_PRECISE(int16_t));
static_assert(IS_NOT_BIT_PRECISE(uint16_t));
static_assert(IS_NOT_BIT_PRECISE(int32_t));
static_assert(IS_NOT_BIT_PRECISE(uint32_t));
static_assert(IS_NOT_BIT_PRECISE(int64_t));
static_assert(IS_NOT_BIT_PRECISE(uint64_t));
static_assert(IS_NOT_BIT_PRECISE(intmax_t));
static_assert(IS_NOT_BIT_PRECISE(uintmax_t));
static_assert(IS_NOT_BIT_PRECISE(intptr_t));
static_assert(IS_NOT_BIT_PRECISE(uintptr_t));
/* FIXME: N3035 also added wording disallowing using a bit-precise integer type
* as the compatible type for an enumerated type. However, we don't have a
* direct way to test that, so we're claiming conformance without test
* coverage.
*/