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