OSDN Git Service

* gcc.dg/nodfp-1.c: New test.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / dfp / compare-rel-dfp.c
1 /* { dg-do run } */
2 /* { dg-options "-std=gnu99 -O0" } */
3
4 /* C99 6.5.8 Relational operators.
5    Compare decimal float values against variables of different types.  */
6
7 extern void abort (void);
8 static int failcnt;
9
10 /* Support compiling the test to report individual failures; default is
11    to abort as soon as a check fails.  */
12 #ifdef DBG
13 #include <stdio.h>
14 #define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
15 #else
16 #define FAILURE abort ();
17 #endif
18
19 _Decimal32 d32;
20 _Decimal64 d64;
21 _Decimal128 d128;
22
23 /* Use some typedefs of decimal float types, too.  */
24 typedef _Decimal32 SDtype;
25 typedef _Decimal64 DDtype;
26 typedef _Decimal128 TDtype;
27
28 SDtype d32b;
29 DDtype d64b;
30 TDtype d128b;
31
32 void
33 inits (void)
34 {
35   d32 = 1.0df;
36   d64 = 3.0dd;
37   d128 = 5.0dl;
38   d32b = -1.0df;
39   d64b = -4.0dd;
40   d128b = -6.0dl;
41 }
42
43 void
44 compare_dfp (void)
45 {
46   if ((d32 > d64) != 0) FAILURE
47   if ((d32 >= d128b) != 1) FAILURE
48
49   if ((d64 < d32) != 0) FAILURE
50   if ((d64 <= d128) != 1) FAILURE
51
52   if ((d128 > d32) != 1) FAILURE
53   if ((d128 >= d64) != 1) FAILURE
54 }
55
56 int
57 main ()
58 {
59   inits ();
60
61   compare_dfp ();
62
63   if (failcnt)
64     abort ();
65   return 0;
66 }