summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fixed-point/call-by-value.c
blob: 8b9d8225db825ee6d892267a88c3f8da8bd69630 (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
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
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */

/* C99 6.9.1(9) Function definitions; parameter has automatic storage.

   Test that actual parameters are passed by value and that modifications
   made within functions are lost on function return.

   This test is copied from gcc.dg/dfp/ and changed for fixed-point types.  */

extern void abort (void);

#define FOO_FUN(NAME,TYPE,VALUE) \
int foo ## NAME (TYPE z) \
{ \
  z = z + VALUE; \
}

#define FOO_TEST(NAME,TYPE,VALUE) \
  { \
    TYPE NAME = VALUE; \
    foo ## NAME (NAME); \
    if (NAME != VALUE) \
      abort (); \
  }

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

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

  return 0;
}