summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fixed-point/operator-unary.c
blob: 5ad420b02c2b40d7c0b4f0edac4d5901edc4e1d0 (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
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */

/* C99 6.5.3 Unary operators & and *.
   Based on the test from ../dfp/.  */

extern void abort (void);

#define UNARY_OPERATOR(TYPE,SUFFIX)	\
do					\
{					\
 TYPE unary_d = 0.1 ## SUFFIX;		\
 TYPE* unary_dp;			\
 /*  & operator.  */			\
 unary_dp = &(unary_d);			\
 /*  * operator.  */			\
 unary_d = *(unary_dp);			\
} while (0)

int
main ()
{
  /*  C99 6.5.3 Unary operators.  */
  UNARY_OPERATOR(short _Fract, hr);
  UNARY_OPERATOR(_Fract, r);
  UNARY_OPERATOR(long _Fract, lr);
  UNARY_OPERATOR(long long _Fract, llr);
  UNARY_OPERATOR(unsigned short _Fract, uhr);
  UNARY_OPERATOR(unsigned _Fract, ur);
  UNARY_OPERATOR(unsigned long _Fract, ulr);
  UNARY_OPERATOR(unsigned long long _Fract, ullr);
  UNARY_OPERATOR(_Sat short _Fract, hr);
  UNARY_OPERATOR(_Sat _Fract, r);
  UNARY_OPERATOR(_Sat long _Fract, lr);
  UNARY_OPERATOR(_Sat long long _Fract, llr);
  UNARY_OPERATOR(_Sat unsigned short _Fract, uhr);
  UNARY_OPERATOR(_Sat unsigned _Fract, ur);
  UNARY_OPERATOR(_Sat unsigned long _Fract, ulr);
  UNARY_OPERATOR(_Sat unsigned long long _Fract, ullr);
  UNARY_OPERATOR(short _Accum, hk);
  UNARY_OPERATOR(_Accum, k);
  UNARY_OPERATOR(long _Accum, lk);
  UNARY_OPERATOR(long long _Accum, llk);
  UNARY_OPERATOR(unsigned short _Accum, uhk);
  UNARY_OPERATOR(unsigned _Accum, uk);
  UNARY_OPERATOR(unsigned long _Accum, ulk);
  UNARY_OPERATOR(unsigned long long _Accum, ullk);
  UNARY_OPERATOR(_Sat short _Accum, hk);
  UNARY_OPERATOR(_Sat _Accum, k);
  UNARY_OPERATOR(_Sat long _Accum, lk);
  UNARY_OPERATOR(_Sat long long _Accum, llk);
  UNARY_OPERATOR(_Sat unsigned short _Accum, uhk);
  UNARY_OPERATOR(_Sat unsigned _Accum, uk);
  UNARY_OPERATOR(_Sat unsigned long _Accum, ulk);
  UNARY_OPERATOR(_Sat unsigned long long _Accum, ullk);

  return 0;
}