brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.8 KiB · e8b1937 Raw
252 lines · c
1// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c17 %s2// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c2x %s3// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=aarch64-none-none4// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=arm-none-none5// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=i386-none-none6// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=mips-none-none7// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=mips64-none-none8// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=msp430-none-none9// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=powerpc64-none-none10// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=powerpc64-none-netbsd11// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=powerpc-none-none12// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=s390x-none-none13// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=sparc-none-none14// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=tce-none-none15// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=x86_64-none-none16// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=x86_64-pc-linux-gnu17// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=i386-mingw3218// RUN: %clang_cc1 %s -ffreestanding -std=c2x -fsyntax-only -triple=xcore-none-none19// expected-no-diagnostics20 21#include <stdint.h>22 23#if __STDC_VERSION__ >= 202311L24/* Validate the standard requirements. */25_Static_assert(SIG_ATOMIC_WIDTH >= 8);26_Static_assert(SIZE_WIDTH >= 16);27_Static_assert(SIZE_WIDTH / __CHAR_BIT__ == sizeof(sizeof(0)));28_Static_assert(WCHAR_WIDTH >= 8);29_Static_assert(WCHAR_WIDTH / __CHAR_BIT__ == sizeof(L't'));30_Static_assert(WINT_WIDTH >= 16);31_Static_assert(UINTPTR_WIDTH >= 16);32_Static_assert(UINTPTR_WIDTH / __CHAR_BIT__ == sizeof(uintptr_t));33_Static_assert(INTPTR_WIDTH == UINTPTR_WIDTH);34_Static_assert(INTPTR_WIDTH / __CHAR_BIT__ == sizeof(intptr_t));35 36/* FIXME: the TCE target is not a conforming C target because it defines these37   values to be less than 64. */38#if !defined(__TCE__)39_Static_assert(UINTMAX_WIDTH >= 64);40_Static_assert(UINTMAX_WIDTH / __CHAR_BIT__ == sizeof(uintmax_t));41_Static_assert(INTMAX_WIDTH == UINTMAX_WIDTH);42_Static_assert(INTMAX_WIDTH / __CHAR_BIT__ == sizeof(intmax_t));43#endif44 45/* NB: WG14 N2412 set this to 17, but WG14 N2808 set it back to 16. */46_Static_assert(PTRDIFF_WIDTH >= 16);47#else48/* None of these are defined. */49int PTRDIFF_WIDTH, SIG_ATOMIC_WIDTH, SIZE_WIDTH, WCHAR_WIDTH, WINT_WIDTH,50    INTPTR_WIDTH, UINTPTR_WIDTH, INTMAX_WIDTH, UINTMAX_WIDTH;51#endif52 53#if defined(INT8_MAX) && __STDC_VERSION__ >= 202311L54_Static_assert(INT8_WIDTH == 8, "");55_Static_assert(UINT8_WIDTH == INT8_WIDTH, "");56_Static_assert(INT8_WIDTH / __CHAR_BIT__ == sizeof(int8_t), "");57_Static_assert(UINT8_WIDTH / __CHAR_BIT__ == sizeof(uint8_t), "");58#else59int INT8_WIDTH, UINT8_WIDTH; /* None of these are defined. */60#endif61#if defined(INT_LEAST8_MAX) && __STDC_VERSION__ >= 202311L62_Static_assert(INT_LEAST8_WIDTH >= 8, "");63_Static_assert(INT_LEAST8_WIDTH / __CHAR_BIT__ == sizeof(int_least8_t), "");64_Static_assert(UINT_LEAST8_WIDTH == INT_LEAST8_WIDTH, "");65_Static_assert(UINT_LEAST8_WIDTH / __CHAR_BIT__ == sizeof(uint_least8_t), "");66#else67int INT_LEAST8_WIDTH, UINT_LEAST8_WIDTH; /* None of these are defined. */68#endif69#if defined(INT_FAST8_MAX) && __STDC_VERSION__ >= 202311L70_Static_assert(INT_FAST8_WIDTH >= 8, "");71_Static_assert(INT_FAST8_WIDTH / __CHAR_BIT__ == sizeof(int_fast8_t), "");72_Static_assert(UINT_FAST8_WIDTH == INT_FAST8_WIDTH, "");73_Static_assert(UINT_FAST8_WIDTH / __CHAR_BIT__ == sizeof(uint_fast8_t), "");74#else75int INT_FAST8_WIDTH, UINT_FAST8_WIDTH; /* None of these are defined. */76#endif77 78#if defined(INT16_MAX) && __STDC_VERSION__ >= 202311L79_Static_assert(INT16_WIDTH == 16, "");80_Static_assert(UINT16_WIDTH == INT16_WIDTH, "");81_Static_assert(INT16_WIDTH / __CHAR_BIT__ == sizeof(int16_t), "");82_Static_assert(UINT16_WIDTH / __CHAR_BIT__ == sizeof(uint16_t), "");83#else84int INT16_WIDTH, UINT16_WIDTH; /* None of these are defined. */85#endif86#if defined(INT_LEAST16_MAX) && __STDC_VERSION__ >= 202311L87_Static_assert(INT_LEAST16_WIDTH >= 16, "");88_Static_assert(INT_LEAST16_WIDTH / __CHAR_BIT__ == sizeof(int_least16_t), "");89_Static_assert(UINT_LEAST16_WIDTH == INT_LEAST16_WIDTH, "");90_Static_assert(UINT_LEAST16_WIDTH / __CHAR_BIT__ == sizeof(uint_least16_t), "");91#else92int INT_LEAST16_WIDTH, UINT_LEAST16_WIDTH; /* None of these are defined. */93#endif94#if defined(INT_FAST16_MAX) && __STDC_VERSION__ >= 202311L95_Static_assert(INT_FAST16_WIDTH >= 16, "");96_Static_assert(INT_FAST16_WIDTH / __CHAR_BIT__ == sizeof(int_fast16_t), "");97_Static_assert(UINT_FAST16_WIDTH == INT_FAST16_WIDTH, "");98_Static_assert(UINT_FAST16_WIDTH / __CHAR_BIT__ == sizeof(int_fast16_t), "");99#else100int INT_FAST16_WIDTH, UINT_FAST16_WIDTH; /* None of these are defined. */101#endif102 103#if defined(INT24_MAX) && __STDC_VERSION__ >= 202311L104_Static_assert(INT24_WIDTH == 24, "");105_Static_assert(UINT24_WIDTH == INT24_WIDTH, "");106_Static_assert(INT24_WIDTH / __CHAR_BIT__ == sizeof(int24_t), "");107_Static_assert(UINT24_WIDTH / __CHAR_BIT__ == sizeof(uint24_t), "");108#else109int INT24_WIDTH, UINT24_WIDTH; /* None of these are defined. */110#endif111#if defined(INT_LEAST24_MAX) && __STDC_VERSION__ >= 202311L112_Static_assert(INT_LEAST24_WIDTH >= 24, "");113_Static_assert(INT_LEAST24_WIDTH / __CHAR_BIT__ == sizeof(int_least24_t), "");114_Static_assert(UINT_LEAST24_WIDTH == INT_LEAST24_WIDTH, "");115_Static_assert(UINT_LEAST24_WIDTH / __CHAR_BIT__ == sizeof(uint_least24_t), "");116#else117int INT_LEAST24_WIDTH, UINT_LEAST24_WIDTH; /* None of these are defined. */118#endif119#if defined(INT_FAST24_MAX) && __STDC_VERSION__ >= 202311L120_Static_assert(INT_FAST24_WIDTH >= 24, "");121_Static_assert(INT_FAST24_WIDTH / __CHAR_BIT__ == sizeof(int_fast24_t), "");122_Static_assert(UINT_FAST24_WIDTH == INT_FAST24_WIDTH, "");123_Static_assert(UINT_FAST24_WIDTH / __CHAR_BIT__ == sizeof(uint_fast24_t), "");124#else125int INT_FAST24_WIDTH, UINT_FAST24_WIDTH; /* None of these are defined. */126#endif127 128#if defined(INT32_MAX) && __STDC_VERSION__ >= 202311L129_Static_assert(INT32_WIDTH == 32, "");130_Static_assert(UINT32_WIDTH == INT32_WIDTH, "");131_Static_assert(INT32_WIDTH / __CHAR_BIT__ == sizeof(int32_t), "");132_Static_assert(UINT32_WIDTH / __CHAR_BIT__ == sizeof(uint32_t), "");133#else134int INT32_WIDTH, UINT32_WIDTH; /* None of these are defined. */135#endif136#if defined(INT_LEAST32_MAX) && __STDC_VERSION__ >= 202311L137_Static_assert(INT_LEAST32_WIDTH >= 32, "");138_Static_assert(INT_LEAST32_WIDTH / __CHAR_BIT__ == sizeof(int_least32_t), "");139_Static_assert(UINT_LEAST32_WIDTH == INT_LEAST32_WIDTH, "");140_Static_assert(UINT_LEAST32_WIDTH / __CHAR_BIT__ == sizeof(uint_least32_t), "");141#else142int INT_LEAST32_WIDTH, UINT_LEAST32_WIDTH; /* None of these are defined. */143#endif144#if defined(INT_FAST32_MAX) && __STDC_VERSION__ >= 202311L145_Static_assert(INT_FAST32_WIDTH >= 32, "");146_Static_assert(INT_FAST32_WIDTH / __CHAR_BIT__ == sizeof(int_fast32_t), "");147_Static_assert(UINT_FAST32_WIDTH == INT_FAST32_WIDTH, "");148_Static_assert(UINT_FAST32_WIDTH / __CHAR_BIT__ == sizeof(uint_fast32_t), "");149#else150int INT_FAST32_WIDTH, UINT_FAST32_WIDTH; /* None of these are defined. */151#endif152 153#if defined(INT40_MAX) && __STDC_VERSION__ >= 202311L154_Static_assert(INT40_WIDTH == 40, "");155_Static_assert(UINT40_WIDTH == INT40_WIDTH, "");156_Static_assert(INT40_WIDTH / __CHAR_BIT__ == sizeof(int40_t), "");157_Static_assert(UINT40_WIDTH / __CHAR_BIT__ == sizeof(uint40_t), "");158#else159int INT40_WIDTH, UINT40_WIDTH; /* None of these are defined. */160#endif161#if defined(INT_LEAST40_MAX) && __STDC_VERSION__ >= 202311L162_Static_assert(INT_LEAST40_WIDTH >= 40, "");163_Static_assert(INT_LEAST40_WIDTH / __CHAR_BIT__ == sizeof(int_least40_t), "");164_Static_assert(UINT_LEAST40_WIDTH == INT_LEAST40_WIDTH, "");165_Static_assert(UINT_LEAST40_WIDTH / __CHAR_BIT__ == sizeof(int_least40_t), "");166#else167int INT_LEAST40_WIDTH, UINT_LEAST40_WIDTH; /* None of these are defined. */168#endif169#if defined(INT_FAST40_MAX) && __STDC_VERSION__ >= 202311L170_Static_assert(INT_FAST40_WIDTH >= 40, "");171_Static_assert(INT_FAST40_WIDTH / __CHAR_BIT__ == sizeof(int_fast40_t), "");172_Static_assert(UINT_FAST40_WIDTH == INT_FAST40_WIDTH, "");173_Static_assert(UINT_FAST40_WIDTH / __CHAR_BIT__ == sizeof(uint_fast40_t), "");174#else175int INT_FAST40_WIDTH, UINT_FAST40_WIDTH; /* None of these are defined. */176#endif177 178#if defined(INT48_MAX) && __STDC_VERSION__ >= 202311L179_Static_assert(INT48_WIDTH == 48, "");180_Static_assert(UINT48_WIDTH == INT48_WIDTH, "");181_Static_assert(INT48_WIDTH / __CHAR_BIT__ == sizeof(int48_t), "");182_Static_assert(UINT48_WIDTH / __CHAR_BIT__ == sizeof(uint48_t), "");183#else184int INT48_WIDTH, UINT48_WIDTH; /* None of these are defined. */185#endif186#if defined(INT_LEAST48_MAX) && __STDC_VERSION__ >= 202311L187_Static_assert(INT_LEAST48_WIDTH >= 48, "");188_Static_assert(INT_LEAST48_WIDTH / __CHAR_BIT__ == sizeof(int_least48_t), "");189_Static_assert(UINT_LEAST48_WIDTH == INT_LEAST48_WIDTH, "");190_Static_assert(UINT_LEAST48_WIDTH / __CHAR_BIT__ == sizeof(int_least48_t), "");191#else192int INT_LEAST48_WIDTH, UINT_LEAST48_WIDTH; /* None of these are defined. */193#endif194#if defined(INT_FAST48_MAX) && __STDC_VERSION__ >= 202311L195_Static_assert(INT_FAST48_WIDTH >= 48, "");196_Static_assert(INT_FAST48_WIDTH / __CHAR_BIT__ == sizeof(int_fast48_t), "");197_Static_assert(UINT_FAST48_WIDTH == INT_FAST48_WIDTH, "");198_Static_assert(UINT_FAST48_WIDTH / __CHAR_BIT__ == sizeof(int_fast48_t), "");199#else200int INT_FAST48_WIDTH, UINT_FAST48_WIDTH; /* None of these are defined. */201#endif202 203#if defined(INT56_MAX) && __STDC_VERSION__ >= 202311L204_Static_assert(INT56_WIDTH == 56, "");205_Static_assert(UINT56_WIDTH == INT56_WIDTH, "");206_Static_assert(INT56_WIDTH / __CHAR_BIT__ == sizeof(int56_t), "");207_Static_assert(UINT56_WIDTH / __CHAR_BIT__ == sizeof(uint56_t), "");208#else209int INT56_WIDTH, UINT56_WIDTH; /* None of these are defined. */210#endif211#if defined(INT_LEAST56_MAX) && __STDC_VERSION__ >= 202311L212_Static_assert(INT_LEAST56_WIDTH >= 56, "");213_Static_assert(INT_LEAST56_WIDTH / __CHAR_BIT__ == sizeof(int_least56_t), "");214_Static_assert(UINT_LEAST56_WIDTH == INT_LEAST56_WIDTH, "");215_Static_assert(UINT_LEAST56_WIDTH / __CHAR_BIT__ == sizeof(int_least56_t), "");216#else217int INT_LEAST56_WIDTH, UINT_LEAST56_WIDTH; /* None of these are defined. */218#endif219#if defined(INT_FAST56_MAX) && __STDC_VERSION__ >= 202311L220_Static_assert(INT_FAST56_WIDTH >= 56, "");221_Static_assert(INT_FAST56_WIDTH / __CHAR_BIT__ == sizeof(int_fast56_t), "");222_Static_assert(UINT_FAST56_WIDTH == INT_FAST56_WIDTH, "");223_Static_assert(UINT_FAST56_WIDTH / __CHAR_BIT__ == sizeof(int_fast56_t), "");224#else225int INT_FAST56_WIDTH, UINT_FAST56_WIDTH; /* None of these are defined. */226#endif227 228#if defined(INT64_MAX) && __STDC_VERSION__ >= 202311L229_Static_assert(INT64_WIDTH == 64, "");230_Static_assert(UINT64_WIDTH == INT64_WIDTH, "");231_Static_assert(INT64_WIDTH / __CHAR_BIT__ == sizeof(int64_t), "");232_Static_assert(UINT64_WIDTH / __CHAR_BIT__ == sizeof(uint64_t), "");233#else234int INT64_WIDTH, UINT64_WIDTH; /* None of these are defined. */235#endif236#if defined(INT_LEAST64_MAX) && __STDC_VERSION__ >= 202311L237_Static_assert(INT_LEAST64_WIDTH >= 64, "");238_Static_assert(INT_LEAST64_WIDTH / __CHAR_BIT__ == sizeof(int_least64_t), "");239_Static_assert(UINT_LEAST64_WIDTH == INT_LEAST64_WIDTH, "");240_Static_assert(UINT_LEAST64_WIDTH / __CHAR_BIT__ == sizeof(int_least64_t), "");241#else242int INT_LEAST64_WIDTH, UINT_LEAST64_WIDTH; /* None of these are defined. */243#endif244#if defined(INT_FAST64_MAX) && __STDC_VERSION__ >= 202311L245_Static_assert(INT_FAST64_WIDTH >= 64, "");246_Static_assert(INT_FAST64_WIDTH / __CHAR_BIT__ == sizeof(int_fast64_t), "");247_Static_assert(UINT_FAST64_WIDTH == INT_FAST64_WIDTH, "");248_Static_assert(UINT_FAST64_WIDTH / __CHAR_BIT__ == sizeof(int_fast64_t), "");249#else250int INT_FAST64_WIDTH, UINT_FAST64_WIDTH; /* None of these are defined. */251#endif252