OSDN Git Service

* gcc.c-torture/execute/ieee/fp-cmp-1.c: Set up signal handler
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / ieee / fp-cmp-1.c
1 #include <signal.h>
2
3 double nan = 1.0/0.0 - 1.0/0.0;
4 double x = 1.0;
5
6 void leave ()
7 {
8   exit (0);
9 }
10
11 main ()
12 {
13 #if ! defined (__vax__) && ! defined (_CRAY)
14   /* Move this line earlier, for architectures (like alpha) that issue 
15      SIGFPE on the first comparisons. */
16 #ifndef SIGNAL_SUPPRESS
17   /* Some machines catches a SIGFPE when a NaN is compared.
18      Let this test succeed o such machines.  */
19   signal (SIGFPE, leave);
20 #endif
21   /* NaN is an IEEE unordered operand.  All these test should be false.  */
22   if (nan == nan)
23     abort ();
24   if (nan != x)
25     x = 1.0;
26   else
27     abort ();
28
29   if (nan < x)
30     abort ();
31   if (nan > x)
32     abort ();
33   if (nan <= x)
34     abort ();
35   if (nan >= x)
36     abort ();
37   if (nan == x)
38     abort ();
39 #endif
40   exit (0);
41 }