2015-10-17 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / c-c++-common / dfp / operator-logical.c
blobc784468c77aef0b8c13ca8467e8ba3271eb32d41
1 /* C99 Logical AND operator.
2 C99 Logical OR operator.
3 Test with decimal float operands. */
5 #include "dfp-dbg.h"
7 #define OPERATE(OPRD1,OPRT,OPRD2,RLT) \
8 do \
9 { \
10 if (( (OPRD1) OPRT (OPRD2) )!= RLT) \
11 __builtin_abort (); \
12 } while (0)
14 #define DECIMAL_LOGICAL_OR(OPRD) \
15 do \
16 { \
17 OPRD = 1.0; \
18 OPERATE(1,||,OPRD,1); \
19 OPERATE(0,||,OPRD,1); \
20 OPERATE(OPRD,||,1,1); \
21 OPERATE(OPRD,||,0,1); \
22 OPRD = 0.0; \
23 OPERATE(1,||,OPRD,1); \
24 OPERATE(0,||,OPRD,0); \
25 OPERATE(OPRD,||,1,1); \
26 OPERATE(OPRD,||,0,0); \
27 } while (0)
29 #define DECIMAL_LOGICAL_AND(OPRD) \
30 do \
31 { \
32 OPRD = 1.0; \
33 OPERATE(1,&&,OPRD,1); \
34 OPERATE(0,&&,OPRD,0); \
35 OPERATE(OPRD,&&,1,1); \
36 OPERATE(OPRD,&&,0,0); \
37 OPRD = 0.0; \
38 OPERATE(1,&&,OPRD,0); \
39 OPERATE(0,&&,OPRD,0); \
40 OPERATE(OPRD,&&,1,0); \
41 OPERATE(OPRD,&&,0,0); \
42 } while (0)
44 int
45 main ()
47 _Decimal32 d32;
48 _Decimal64 d64;
49 _Decimal128 d128;
51 /* C99 Section 6.5.{13,14} Logical operator. Constraints Each of the
52 operands shall have scalar type. DFP types would obey this. */
53 DECIMAL_LOGICAL_OR (d32);
54 DECIMAL_LOGICAL_AND (d32);
56 DECIMAL_LOGICAL_OR (d64);
57 DECIMAL_LOGICAL_AND (d64);
59 DECIMAL_LOGICAL_OR (d128);
60 DECIMAL_LOGICAL_AND (d128);
62 return 0;