(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
limits-width-2.c
       1  /* Test C2X width macros in <limits.h>.  */
       2  /* { dg-do compile } */
       3  /* { dg-options "-std=c2x" } */
       4  
       5  #include <limits.h>
       6  
       7  #define CHECK_WIDTH(TYPE, MAX, WIDTH)					\
       8    _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \
       9  		  "width must match type")
      10  
      11  #ifndef CHAR_WIDTH
      12  # error "missing CHAR_WIDTH"
      13  #endif
      14  CHECK_WIDTH (char, CHAR_MAX, CHAR_WIDTH);
      15  #ifndef SCHAR_WIDTH
      16  # error "missing SCHAR_WIDTH"
      17  #endif
      18  CHECK_WIDTH (signed char, SCHAR_MAX, SCHAR_WIDTH);
      19  #ifndef UCHAR_WIDTH
      20  # error "missing UCHAR_WIDTH"
      21  #endif
      22  CHECK_WIDTH (unsigned char, UCHAR_MAX, UCHAR_WIDTH);
      23  #ifndef SHRT_WIDTH
      24  # error "missing SHRT_WIDTH"
      25  #endif
      26  CHECK_WIDTH (signed short, SHRT_MAX, SHRT_WIDTH);
      27  #ifndef USHRT_WIDTH
      28  # error "missing USHRT_WIDTH"
      29  #endif
      30  CHECK_WIDTH (unsigned short, USHRT_MAX, USHRT_WIDTH);
      31  #ifndef INT_WIDTH
      32  # error "missing INT_WIDTH"
      33  #endif
      34  CHECK_WIDTH (signed int, INT_MAX, INT_WIDTH);
      35  #ifndef UINT_WIDTH
      36  # error "missing UINT_WIDTH"
      37  #endif
      38  CHECK_WIDTH (unsigned int, UINT_MAX, UINT_WIDTH);
      39  #ifndef LONG_WIDTH
      40  # error "missing LONG_WIDTH"
      41  #endif
      42  CHECK_WIDTH (signed long, LONG_MAX, LONG_WIDTH);
      43  #ifndef ULONG_WIDTH
      44  # error "missing ULONG_WIDTH"
      45  #endif
      46  CHECK_WIDTH (unsigned long, ULONG_MAX, ULONG_WIDTH);
      47  #ifndef LLONG_WIDTH
      48  # error "missing LLONG_WIDTH"
      49  #endif
      50  CHECK_WIDTH (signed long long, LLONG_MAX, LLONG_WIDTH);
      51  #ifndef ULLONG_WIDTH
      52  # error "missing ULLONG_WIDTH"
      53  #endif
      54  CHECK_WIDTH (unsigned long long, ULLONG_MAX, ULLONG_WIDTH);