2008-03-21 Janne Blomqvist <jb@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / fixed-point / operator-bitwise.c
blob31aecf5585813e2e1e9de6322e3bb1883285d166
1 /* { dg-do compile } */
2 /* { dg-options "-std=gnu99" } */
4 /* C99 6.5.10: Bitwise AND operator.
5 C99 6.5.11: Bitwise exclusive OR operator.
6 C99 6.5.12: Bitwise inclusive OR operator.
8 Test that these operators do not accept fixed-point operands.
9 Based on the test from ../dfp/. */
11 extern void abort (void);
13 #define OPERATE(OPRD1,OPRT,OPRD2) \
14 do \
15 { \
16 OPRD1 OPRT OPRD2; \
17 } while (0)
21 #define BITWISE_OPERATOR(OPRT,OPRD) \
22 do \
23 { \
24 OPERATE(OPRD,OPRT,1); \
25 OPERATE(OPRD,OPRT,0); \
26 OPERATE(OPRD,OPRT,0x15); \
27 OPERATE(0,OPRT,OPRD); \
28 OPERATE(1,OPRT,OPRD); \
29 OPERATE(0x15,OPRT,OPRD); \
30 } while (0)
32 void operator_notfor_fixed_point()
34 short _Fract sf;
35 _Fract f;
36 long _Fract lf;
37 long long _Fract llf;
38 unsigned short _Fract usf;
39 unsigned _Fract uf;
40 unsigned long _Fract ulf;
41 unsigned long long _Fract ullf;
42 _Sat short _Fract Ssf;
43 _Sat _Fract Sf;
44 _Sat long _Fract Slf;
45 _Sat long long _Fract Sllf;
46 _Sat unsigned short _Fract Susf;
47 _Sat unsigned _Fract Suf;
48 _Sat unsigned long _Fract Sulf;
49 _Sat unsigned long long _Fract Sullf;
50 short _Accum sa;
51 _Accum a;
52 long _Accum la;
53 long long _Accum lla;
54 unsigned short _Accum usa;
55 unsigned _Accum ua;
56 unsigned long _Accum ula;
57 unsigned long long _Accum ulla;
58 _Sat short _Accum Ssa;
59 _Sat _Accum Sa;
60 _Sat long _Accum Sla;
61 _Sat long long _Accum Slla;
62 _Sat unsigned short _Accum Susa;
63 _Sat unsigned _Accum Sua;
64 _Sat unsigned long _Accum Sula;
65 _Sat unsigned long long _Accum Sulla;
67 /* C99 Section 6.5.{10,11,12} Bitwise operator. Constraints: Each of
68 the operands shall have integer type. Fixed-point type is rejected
69 by compiler when bitwise operation is performed. */
71 BITWISE_OPERATOR(&,sf); /* { dg-error "invalid operands to binary" } */
72 BITWISE_OPERATOR(|,sf); /* { dg-error "invalid operands to binary" } */
73 BITWISE_OPERATOR(^,sf); /* { dg-error "invalid operands to binary" } */
74 BITWISE_OPERATOR(&,f); /* { dg-error "invalid operands to binary" } */
75 BITWISE_OPERATOR(|,f); /* { dg-error "invalid operands to binary" } */
76 BITWISE_OPERATOR(^,f); /* { dg-error "invalid operands to binary" } */
77 BITWISE_OPERATOR(&,lf); /* { dg-error "invalid operands to binary" } */
78 BITWISE_OPERATOR(|,lf); /* { dg-error "invalid operands to binary" } */
79 BITWISE_OPERATOR(^,lf); /* { dg-error "invalid operands to binary" } */
80 BITWISE_OPERATOR(&,llf); /* { dg-error "invalid operands to binary" } */
81 BITWISE_OPERATOR(|,llf); /* { dg-error "invalid operands to binary" } */
82 BITWISE_OPERATOR(^,llf); /* { dg-error "invalid operands to binary" } */
83 BITWISE_OPERATOR(&,usf); /* { dg-error "invalid operands to binary" } */
84 BITWISE_OPERATOR(|,usf); /* { dg-error "invalid operands to binary" } */
85 BITWISE_OPERATOR(^,usf); /* { dg-error "invalid operands to binary" } */
86 BITWISE_OPERATOR(&,uf); /* { dg-error "invalid operands to binary" } */
87 BITWISE_OPERATOR(|,uf); /* { dg-error "invalid operands to binary" } */
88 BITWISE_OPERATOR(^,uf); /* { dg-error "invalid operands to binary" } */
89 BITWISE_OPERATOR(&,ulf); /* { dg-error "invalid operands to binary" } */
90 BITWISE_OPERATOR(|,ulf); /* { dg-error "invalid operands to binary" } */
91 BITWISE_OPERATOR(^,ulf); /* { dg-error "invalid operands to binary" } */
92 BITWISE_OPERATOR(&,ullf); /* { dg-error "invalid operands to binary" } */
93 BITWISE_OPERATOR(|,ullf); /* { dg-error "invalid operands to binary" } */
94 BITWISE_OPERATOR(^,ullf); /* { dg-error "invalid operands to binary" } */
95 BITWISE_OPERATOR(&,Ssf); /* { dg-error "invalid operands to binary" } */
96 BITWISE_OPERATOR(|,Ssf); /* { dg-error "invalid operands to binary" } */
97 BITWISE_OPERATOR(^,Ssf); /* { dg-error "invalid operands to binary" } */
98 BITWISE_OPERATOR(&,Sf); /* { dg-error "invalid operands to binary" } */
99 BITWISE_OPERATOR(|,Sf); /* { dg-error "invalid operands to binary" } */
100 BITWISE_OPERATOR(^,Sf); /* { dg-error "invalid operands to binary" } */
101 BITWISE_OPERATOR(&,Slf); /* { dg-error "invalid operands to binary" } */
102 BITWISE_OPERATOR(|,Slf); /* { dg-error "invalid operands to binary" } */
103 BITWISE_OPERATOR(^,Slf); /* { dg-error "invalid operands to binary" } */
104 BITWISE_OPERATOR(&,Sllf); /* { dg-error "invalid operands to binary" } */
105 BITWISE_OPERATOR(|,Sllf); /* { dg-error "invalid operands to binary" } */
106 BITWISE_OPERATOR(^,Sllf); /* { dg-error "invalid operands to binary" } */
107 BITWISE_OPERATOR(&,Susf); /* { dg-error "invalid operands to binary" } */
108 BITWISE_OPERATOR(|,Susf); /* { dg-error "invalid operands to binary" } */
109 BITWISE_OPERATOR(^,Susf); /* { dg-error "invalid operands to binary" } */
110 BITWISE_OPERATOR(&,Suf); /* { dg-error "invalid operands to binary" } */
111 BITWISE_OPERATOR(|,Suf); /* { dg-error "invalid operands to binary" } */
112 BITWISE_OPERATOR(^,Suf); /* { dg-error "invalid operands to binary" } */
113 BITWISE_OPERATOR(&,Sulf); /* { dg-error "invalid operands to binary" } */
114 BITWISE_OPERATOR(|,Sulf); /* { dg-error "invalid operands to binary" } */
115 BITWISE_OPERATOR(^,Sulf); /* { dg-error "invalid operands to binary" } */
116 BITWISE_OPERATOR(&,Sullf); /* { dg-error "invalid operands to binary" } */
117 BITWISE_OPERATOR(|,Sullf); /* { dg-error "invalid operands to binary" } */
118 BITWISE_OPERATOR(^,Sullf); /* { dg-error "invalid operands to binary" } */
119 BITWISE_OPERATOR(&,sa); /* { dg-error "invalid operands to binary" } */
120 BITWISE_OPERATOR(|,sa); /* { dg-error "invalid operands to binary" } */
121 BITWISE_OPERATOR(^,sa); /* { dg-error "invalid operands to binary" } */
122 BITWISE_OPERATOR(&,a); /* { dg-error "invalid operands to binary" } */
123 BITWISE_OPERATOR(|,a); /* { dg-error "invalid operands to binary" } */
124 BITWISE_OPERATOR(^,a); /* { dg-error "invalid operands to binary" } */
125 BITWISE_OPERATOR(&,la); /* { dg-error "invalid operands to binary" } */
126 BITWISE_OPERATOR(|,la); /* { dg-error "invalid operands to binary" } */
127 BITWISE_OPERATOR(^,la); /* { dg-error "invalid operands to binary" } */
128 BITWISE_OPERATOR(&,lla); /* { dg-error "invalid operands to binary" } */
129 BITWISE_OPERATOR(|,lla); /* { dg-error "invalid operands to binary" } */
130 BITWISE_OPERATOR(^,lla); /* { dg-error "invalid operands to binary" } */
131 BITWISE_OPERATOR(&,usa); /* { dg-error "invalid operands to binary" } */
132 BITWISE_OPERATOR(|,usa); /* { dg-error "invalid operands to binary" } */
133 BITWISE_OPERATOR(^,usa); /* { dg-error "invalid operands to binary" } */
134 BITWISE_OPERATOR(&,ua); /* { dg-error "invalid operands to binary" } */
135 BITWISE_OPERATOR(|,ua); /* { dg-error "invalid operands to binary" } */
136 BITWISE_OPERATOR(^,ua); /* { dg-error "invalid operands to binary" } */
137 BITWISE_OPERATOR(&,ula); /* { dg-error "invalid operands to binary" } */
138 BITWISE_OPERATOR(|,ula); /* { dg-error "invalid operands to binary" } */
139 BITWISE_OPERATOR(^,ula); /* { dg-error "invalid operands to binary" } */
140 BITWISE_OPERATOR(&,ulla); /* { dg-error "invalid operands to binary" } */
141 BITWISE_OPERATOR(|,ulla); /* { dg-error "invalid operands to binary" } */
142 BITWISE_OPERATOR(^,ulla); /* { dg-error "invalid operands to binary" } */
143 BITWISE_OPERATOR(&,Ssa); /* { dg-error "invalid operands to binary" } */
144 BITWISE_OPERATOR(|,Ssa); /* { dg-error "invalid operands to binary" } */
145 BITWISE_OPERATOR(^,Ssa); /* { dg-error "invalid operands to binary" } */
146 BITWISE_OPERATOR(&,Sa); /* { dg-error "invalid operands to binary" } */
147 BITWISE_OPERATOR(|,Sa); /* { dg-error "invalid operands to binary" } */
148 BITWISE_OPERATOR(^,Sa); /* { dg-error "invalid operands to binary" } */
149 BITWISE_OPERATOR(&,Sla); /* { dg-error "invalid operands to binary" } */
150 BITWISE_OPERATOR(|,Sla); /* { dg-error "invalid operands to binary" } */
151 BITWISE_OPERATOR(^,Sla); /* { dg-error "invalid operands to binary" } */
152 BITWISE_OPERATOR(&,Slla); /* { dg-error "invalid operands to binary" } */
153 BITWISE_OPERATOR(|,Slla); /* { dg-error "invalid operands to binary" } */
154 BITWISE_OPERATOR(^,Slla); /* { dg-error "invalid operands to binary" } */
155 BITWISE_OPERATOR(&,Susa); /* { dg-error "invalid operands to binary" } */
156 BITWISE_OPERATOR(|,Susa); /* { dg-error "invalid operands to binary" } */
157 BITWISE_OPERATOR(^,Susa); /* { dg-error "invalid operands to binary" } */
158 BITWISE_OPERATOR(&,Sua); /* { dg-error "invalid operands to binary" } */
159 BITWISE_OPERATOR(|,Sua); /* { dg-error "invalid operands to binary" } */
160 BITWISE_OPERATOR(^,Sua); /* { dg-error "invalid operands to binary" } */
161 BITWISE_OPERATOR(&,Sula); /* { dg-error "invalid operands to binary" } */
162 BITWISE_OPERATOR(|,Sula); /* { dg-error "invalid operands to binary" } */
163 BITWISE_OPERATOR(^,Sula); /* { dg-error "invalid operands to binary" } */
164 BITWISE_OPERATOR(&,Sulla); /* { dg-error "invalid operands to binary" } */
165 BITWISE_OPERATOR(|,Sulla); /* { dg-error "invalid operands to binary" } */
166 BITWISE_OPERATOR(^,Sulla); /* { dg-error "invalid operands to binary" } */