File: operator-cond.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (101 lines) | stat: -rw-r--r-- 2,158 bytes parent folder | download | duplicates (10)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */

/* C99 6.5.15 Conditional operator.
   Test with fixed-point operands.
   Based on the test from ../dfp/.  */

extern void abort (void);
volatile int yes, no;

#define FUNC(TYPE,NAME,PF) \
volatile TYPE NAME ## a, NAME ## b, NAME ## c; \
void \
init_ ## NAME () \
{ \
  NAME ## b = 0.2 ## PF; \
  NAME ## c = 0.3 ## PF; \
  yes = 1; \
  no = 0; \
}

FUNC (short _Fract, sf, hr)
FUNC (_Fract, f, r)
FUNC (long _Fract, lf, lr)
FUNC (long long _Fract, llf, llr)
FUNC (unsigned short _Fract, usf, uhr)
FUNC (unsigned _Fract, uf, ur)
FUNC (unsigned long _Fract, ulf, ulr)
FUNC (long long _Fract, ullf, ullr)
FUNC (_Sat short _Fract, Ssf, hr)
FUNC (_Sat _Fract, Sf, r)
FUNC (_Sat long _Fract, Slf, lr)
FUNC (_Sat long long _Fract, Sllf, llr)
FUNC (_Sat unsigned short _Fract, Susf, uhr)
FUNC (_Sat unsigned _Fract, Suf, ur)
FUNC (_Sat unsigned long _Fract, Sulf, ulr)
FUNC (_Sat long long _Fract, Sullf, ullr)
FUNC (short _Accum, sa, hk)
FUNC (_Accum, a, k)
FUNC (long _Accum, la, lk)
FUNC (long long _Accum, lla, llk)
FUNC (unsigned short _Accum, usa, uhk)
FUNC (unsigned _Accum, ua, uk)
FUNC (unsigned long _Accum, ula, ulk)
FUNC (long long _Accum, ulla, ullk)
FUNC (_Sat short _Accum, Ssa, hk)
FUNC (_Sat _Accum, Sa, k)
FUNC (_Sat long _Accum, Sla, lk)
FUNC (_Sat long long _Accum, Slla, llk)
FUNC (_Sat unsigned short _Accum, Susa, uhk)
FUNC (_Sat unsigned _Accum, Sua, uk)
FUNC (_Sat unsigned long _Accum, Sula, ulk)
FUNC (_Sat long long _Accum, Sulla, ullk)

int
main ()
{
#define TEST(NAME) \
  init_ ## NAME (); \
  NAME ## a = yes ? NAME ## b : NAME ## c; \
  if (NAME ## a != NAME ## b) \
    abort (); \
  NAME ## a = no ? NAME ## b : NAME ## c; \
  if (NAME ## a != NAME ## c) \
    abort ();

  TEST(sf)
  TEST(f)
  TEST(lf)
  TEST(llf)
  TEST(usf)
  TEST(uf)
  TEST(ulf)
  TEST(ullf)
  TEST(Ssf)
  TEST(Sf)
  TEST(Slf)
  TEST(Sllf)
  TEST(Susf)
  TEST(Suf)
  TEST(Sulf)
  TEST(Sullf)
  TEST(sa)
  TEST(a)
  TEST(la)
  TEST(lla)
  TEST(usa)
  TEST(ua)
  TEST(ula)
  TEST(ulla)
  TEST(Ssa)
  TEST(Sa)
  TEST(Sla)
  TEST(Slla)
  TEST(Susa)
  TEST(Sua)
  TEST(Sula)
  TEST(Sulla)

  return 0;
}