(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
pr94439.c
       1  /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
       2  /* { dg-additional-options "-flive-patching=inline-clone -funroll-loops -fno-tree-forwprop -fno-expensive-optimizations -mstack-arg-probe -fcompare-debug" } */
       3  /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
       4  
       5  extern void exit (int);
       6  extern void abort (void);
       7  
       8  #define COMPARE_BODY(A, B, TYPE, COPYSIGN)				\
       9    do {									\
      10      TYPE s1 = COPYSIGN ((TYPE) 1.0, A);					\
      11      TYPE s2 = COPYSIGN ((TYPE) 1.0, B);					\
      12      if (s1 != s2)							\
      13        abort ();								\
      14      if ((__builtin_isnan (A) != 0) != (__builtin_isnan (B) != 0))	\
      15        abort ();								\
      16      if ((A != B) != (__builtin_isnan (A) != 0))				\
      17        abort ();								\
      18    } while (0)
      19  
      20  void
      21  comparel (long double a, long double b)
      22  {
      23    COMPARE_BODY (a, b, long double, __builtin_copysignl);
      24  }
      25  
      26  void
      27  comparecl (_Complex long double a, long double r, long double i)
      28  {
      29    comparel (__real__ a, r);
      30    comparel (__imag__ a, i);
      31  }
      32  
      33  #define VERIFY(A, B, TYPE, COMPARE)			\
      34    do {							\
      35      TYPE a = A;						\
      36      TYPE b = B;						\
      37      _Complex TYPE cr = __builtin_complex (a, b);	\
      38      static _Complex TYPE cs = __builtin_complex (A, B);	\
      39      COMPARE (cr, A, B);					\
      40      COMPARE (cs, A, B);					\
      41    } while (0)
      42  
      43  #define ALL_CHECKS(PZ, NZ, NAN, INF, TYPE, COMPARE)	\
      44    do {							\
      45      VERIFY (NAN, NZ, TYPE, COMPARE);			\
      46      VERIFY (INF, NZ, TYPE, COMPARE);			\
      47      VERIFY (INF, NAN, TYPE, COMPARE);			\
      48      VERIFY (INF, INF, TYPE, COMPARE);			\
      49    } while (0)
      50  
      51  void
      52  check_long_double (void)
      53  {
      54    ALL_CHECKS (0.0l, -0.0l, __builtin_nanl(""), __builtin_infl(), long double, comparecl);
      55  }