aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/dfp/operator-cond.c
blob: 140dd95074a805377b5e24eb0ce4818e82f21834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* { dg-options "-O0" } */

/* C99 6.5.15 Conditional operator.
   Test with decimal float operands.  */

#include "dfp-dbg.h"

volatile _Decimal32 d32a, d32b, d32c;
volatile _Decimal64 d64a, d64b, d64c;
volatile _Decimal128 d128a, d128b, d128c;
volatile int i, yes, no;

void
init ()
{
  d32b = 123.456e94df;
  d64b = 12.3456789012345e383dd;
  d128b = 12345.6789012345678901e4000dl;

  d32c = 1.3df;
  d64c = 1.2dd;
  d128c = 1.1dl;

  i = 2;
  yes = 1;
  no = 0;
}

int
main ()
{
  init ();

  /* Operands and the result are all the same decimal float type.  */
  d32a = yes ? d32b : d32c;
  if (d32a != d32b)
    FAILURE
  d64a = no ? d64b : d64c;
  if (d64a != d64c)
    FAILURE
  d128a = yes ? d128b : d128c;
  if (d128a != d128b)
    FAILURE

  /* Operand types are different.  */
  d128a = yes ? d32b : d64b;
  if (d128a != d32b)
    FAILURE
  d128a = yes ? d128b : d64b;
  if (d128a != d128b)
    FAILURE
  d128a = no ? d32b : d128b;
  if (d128a != d128b)
    FAILURE

  FINISH
}