1 /* { dg-do run } */
2 /* { dg-options "-std=gnu99" } */
3 
4 /* C99 6.5.2.2 Function calls.
5    Test scalar passing and return values involving fixed-point types.
6    Based on the test from ../dfp/.  */
7 
8 extern void abort (void);
9 
10 /* A handful of functions that return the Nth argument of
11    an incoming array.  */
12 
13 #define FUNC(TYPE,NAME) \
14 TYPE NAME ## 0 (TYPE arg0, TYPE arg1, TYPE arg2, TYPE arg3, TYPE arg4) \
15   { return arg0; } \
16 TYPE NAME ## 1 (TYPE arg0, TYPE arg1, TYPE arg2, TYPE arg3, TYPE arg4) \
17   { return arg1; } \
18 TYPE NAME ## 2 (TYPE arg0, TYPE arg1, TYPE arg2, TYPE arg3, TYPE arg4) \
19   { return arg2; } \
20 TYPE NAME ## 3 (TYPE arg0, TYPE arg1, TYPE arg2, TYPE arg3, TYPE arg4) \
21   { return arg3; } \
22 TYPE NAME ## 4 (TYPE arg0, TYPE arg1, TYPE arg2, TYPE arg3, TYPE arg4) \
23   { return arg4; }
24 
FUNC(short _Fract,sf)25 FUNC (short _Fract, sf)
26 FUNC (_Fract, f)
27 FUNC (long _Fract, lf)
28 FUNC (long long _Fract, llf)
29 FUNC (unsigned short _Fract, usf)
30 FUNC (unsigned _Fract, uf)
31 FUNC (unsigned long _Fract, ulf)
32 FUNC (unsigned long long _Fract, ullf)
33 FUNC (_Sat short _Fract, Ssf)
34 FUNC (_Sat _Fract, Sf)
35 FUNC (_Sat long _Fract, Slf)
36 FUNC (_Sat long long _Fract, Sllf)
37 FUNC (_Sat unsigned short _Fract, Susf)
38 FUNC (_Sat unsigned _Fract, Suf)
39 FUNC (_Sat unsigned long _Fract, Sulf)
40 FUNC (_Sat unsigned long long _Fract, Sullf)
41 FUNC (short _Accum, sa)
42 FUNC (_Accum, a)
43 FUNC (long _Accum, la)
44 FUNC (long long _Accum, lla)
45 FUNC (unsigned short _Accum, usa)
46 FUNC (unsigned _Accum, ua)
47 FUNC (unsigned long _Accum, ula)
48 FUNC (unsigned long long _Accum, ulla)
49 FUNC (_Sat short _Accum, Ssa)
50 FUNC (_Sat _Accum, Sa)
51 FUNC (_Sat long _Accum, Sla)
52 FUNC (_Sat long long _Accum, Slla)
53 FUNC (_Sat unsigned short _Accum, Susa)
54 FUNC (_Sat unsigned _Accum, Sua)
55 FUNC (_Sat unsigned long _Accum, Sula)
56 FUNC (_Sat unsigned long long _Accum, Sulla)
57 
58 int main()
59 {
60 #define TEST(TYPE,NAME,PF) \
61   { \
62     if (NAME ## 0 (0.1 ## PF, 0.2 ## PF, 0.3 ## PF, 0.4 ## PF, 0.5 ## PF) \
63 	!= 0.1 ## PF) abort (); \
64     if (NAME ## 1 (0.1 ## PF, 0.2 ## PF, 0.3 ## PF, 0.4 ## PF, 0.5 ## PF) \
65 	!= 0.2 ## PF) abort (); \
66     if (NAME ## 2 (0.1 ## PF, 0.2 ## PF, 0.3 ## PF, 0.4 ## PF, 0.5 ## PF) \
67 	!= 0.3 ## PF) abort (); \
68     if (NAME ## 3 (0.1 ## PF, 0.2 ## PF, 0.3 ## PF, 0.4 ## PF, 0.5 ## PF) \
69 	!= 0.4 ## PF) abort (); \
70     if (NAME ## 4 (0.1 ## PF, 0.2 ## PF, 0.3 ## PF, 0.4 ## PF, 0.5 ## PF) \
71 	!= 0.5 ## PF) abort (); \
72   }
73 
74   TEST (short _Fract, sf, hr)
75   TEST (_Fract, f, r)
76   TEST (long _Fract, lf, lr)
77   TEST (long long _Fract, llf, llr)
78   TEST (unsigned short _Fract, usf, uhr)
79   TEST (unsigned _Fract, uf, ur)
80   TEST (unsigned long _Fract, ulf, ulr)
81   TEST (unsigned long long _Fract, ullf, ullr)
82   TEST (_Sat short _Fract, Ssf, hr)
83   TEST (_Sat _Fract, Sf, r)
84   TEST (_Sat long _Fract, Slf, lr)
85   TEST (_Sat long long _Fract, Sllf, llr)
86   TEST (_Sat unsigned short _Fract, Susf, uhr)
87   TEST (_Sat unsigned _Fract, Suf, ur)
88   TEST (_Sat unsigned long _Fract, Sulf, ulr)
89   TEST (_Sat unsigned long long _Fract, Sullf, ullr)
90   TEST (short _Accum, sa, hk)
91   TEST (_Accum, a, k)
92   TEST (long _Accum, la, lk)
93   TEST (long long _Accum, lla, llk)
94   TEST (unsigned short _Accum, usa, uhk)
95   TEST (unsigned _Accum, ua, uk)
96   TEST (unsigned long _Accum, ula, ulk)
97   TEST (unsigned long long _Accum, ulla, ullk)
98   TEST (_Sat short _Accum, Ssa, hk)
99   TEST (_Sat _Accum, Sa, k)
100   TEST (_Sat long _Accum, Sla, lk)
101   TEST (_Sat long long _Accum, Slla, llk)
102   TEST (_Sat unsigned short _Accum, Susa, uhk)
103   TEST (_Sat unsigned _Accum, Sua, uk)
104   TEST (_Sat unsigned long _Accum, Sula, ulk)
105   TEST (_Sat unsigned long long _Accum, Sulla, ullk)
106 
107   return 0;
108 }
109