(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
c2x-float-4.c
       1  /* Test NAN macro.  */
       2  /* { dg-do run } */
       3  /* { dg-options "-std=c2x -pedantic-errors" } */
       4  /* { dg-add-options ieee } */
       5  
       6  #include <float.h>
       7  
       8  /* This should be defined if and only if quiet NaNs are supported for
       9     type float.  If the testsuite gains effective-target support for
      10     targets not supporting NaNs, or not supporting them for all types,
      11     this test should be split into versions for targets with and
      12     without NaNs for float.  */
      13  #ifndef NAN
      14  #error "NAN undefined"
      15  #endif
      16  
      17  volatile float f = NAN;
      18  
      19  extern void abort (void);
      20  extern void exit (int);
      21  
      22  int
      23  main (void)
      24  {
      25    (void) _Generic (NAN, float : 0);
      26    if (!__builtin_isnan (NAN))
      27      abort ();
      28    if (!__builtin_isnan (f))
      29      abort ();
      30    if (!__builtin_isnan (f + f))
      31      abort ();
      32    exit (0);
      33  }