1 /* { dg-do run } */
2 /* { dg-add-options ieee } */
3 /* { dg-require-effective-target fenv_exceptions } */
4 /* { dg-skip-if "fenv" { powerpc-ibm-aix* } } */
5 
6 #include <fenv.h>
7 
8 #define TEST_C_NOEX(CMP, S)			\
9   r = nan##S CMP arg##S;			\
10   if (fetestexcept (FE_INVALID))		\
11     __builtin_abort ()
12 
13 #define TEST_B_NOEX(FN, S)			\
14   r = __builtin_##FN (nan##S, arg##S);		\
15   if (fetestexcept (FE_INVALID))		\
16     __builtin_abort ()
17 
18 #define TEST_C_EX(CMP, S)			\
19   r = nan##S CMP arg##S;			\
20   if (!fetestexcept (FE_INVALID))		\
21     __builtin_abort ();				\
22   feclearexcept (FE_INVALID)
23 
24 #define TEST(TYPE, S)				\
25   volatile TYPE nan##S = __builtin_nan##S ("");	\
26   volatile TYPE arg##S = 1.0##S;		\
27 						\
28   TEST_C_NOEX (==, S);				\
29   TEST_C_NOEX (!=, S);				\
30 						\
31   TEST_B_NOEX (isgreater, S);			\
32   TEST_B_NOEX (isless, S);			\
33   TEST_B_NOEX (isgreaterequal, S);		\
34   TEST_B_NOEX (islessequal, S);			\
35 						\
36   TEST_B_NOEX (islessgreater, S);		\
37   TEST_B_NOEX (isunordered, S);			\
38 						\
39   TEST_C_EX (>, S);				\
40   TEST_C_EX (<, S);				\
41   TEST_C_EX (>=, S);				\
42   TEST_C_EX (<=, S)
43 
44 int
main(void)45 main (void)
46 {
47   volatile int r;
48 
49   feclearexcept (FE_INVALID);
50 
51   TEST (float, f);
52   TEST (double, );
53 #if !defined(__hppa__) || !defined(__hpux__)
54   /* Long double on hppa*-hpux* is implemented in software and the routines
55      in fenv.h do not support it.  */
56   TEST (long double, l);
57 #endif
58 
59   return 0;
60 }
61