8e8a922f371b4f6c853f85be0537b54b775205c0
1 /* { dg-options "-std=gnu99" } */
3 /* C99 6.5.16 Assignment operators.
4    Verify the compound assignment operator for decimal float types,
5    using it with other decimal float types, integers, and other binary
6    float types cast to decimal float types.  */
8 extern void abort (void);
10 #define OPERATE(OPRD1,OPRT,OPRD2,RLT)           \
11   if (( OPRD1 OPRT OPRD2 )!= RLT)               \
12     abort ();
14 #define DECIMAL_COMPOUND_ASSIGNMENT(TYPE, OPRD) \
15 {                                               \
16   _Decimal##TYPE d = OPRD;                      \
17   OPERATE(d,+=,1,(OPRD + 1));           \
18   d = OPRD;                             \
19   OPERATE(d,+=,0,OPRD);                 \
20   d = OPRD;                             \
21   OPERATE(d,+=,(-1),(OPRD - 1));        \
22   d = OPRD;                             \
23   OPERATE(d,+=,d32a,(OPRD + d32a));     \
24   d = OPRD;                             \
25   OPERATE(d,+=,d64a,(OPRD + d64a));     \
26   d = OPRD;                             \
27   OPERATE(d,+=,d128a,(OPRD + d128a));   \
28   d = OPRD;                             \
29   OPERATE(d,+=,(_Decimal##TYPE)1.1,(OPRD + (_Decimal##TYPE)1.1));       \
30   d = OPRD;                             \
31   OPERATE(d,+=,(_Decimal##TYPE)2.2f,(OPRD + (_Decimal##TYPE)2.2f));     \
32   d = OPRD;                             \
33   OPERATE(d,-=,1,(OPRD - 1));           \
34   d = OPRD;                             \
35   OPERATE(d,-=,0,OPRD);                 \
36   d = OPRD;                             \
37   OPERATE(d,-=,(-1),(OPRD + 1));        \
38   d = OPRD;                             \
39   OPERATE(d,-=,d32a,OPRD-d32a);         \
40   d = OPRD;                             \
41   OPERATE(d,-=,d64a,OPRD-d64a);         \
42   d = OPRD;                             \
43   OPERATE(d,-=,d128a,OPRD-d128a);       \
44 }
46 int
47 main ()
48 {
49   _Decimal32 d32 = 1.23456df, d32a = 1.2df;
50   _Decimal64 d64 = 23.456789dd, d64a = 2.8dd;
51   _Decimal128 d128 = 345.67890123456789dl, d128a = 4.7dl;
53   DECIMAL_COMPOUND_ASSIGNMENT(32, d32);
54   DECIMAL_COMPOUND_ASSIGNMENT(64, d64);
55   DECIMAL_COMPOUND_ASSIGNMENT(128, d128);
57   return 0;
58 }