1 /* PR 7543. Test operation of -Wparentheses. Precedence warnings.
3 /* { dg-do compile } */
4 /* { dg-options "-Wparentheses" } */
5 // C++ version of Wparentheses-11.c
9 bar (int a, int b, int c)
11 foo (!a & b); /* { dg-warning "parentheses" "correct warning" } */
23 foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */
35 foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" } */
47 foo (!a | b); /* { dg-warning "parentheses" "correct warning" } */
59 foo (!a | 2); /* { dg-warning "parentheses" "correct warning" } */
71 foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" } */
84 foo (b & !a); /* { dg-bogus "parentheses" "bogus warning" } */
96 foo (2 & !a); /* { dg-bogus "parentheses" "correct warning" } */
108 foo (2 & !1); /* { dg-bogus "parentheses" "correct warning" } */
120 foo (b | !a); /* { dg-bogus "parentheses" "correct warning" } */
132 foo (2 | !a); /* { dg-bogus "parentheses" "correct warning" } */
144 foo (2 | !1); /* { dg-bogus "parentheses" "correct warning" } */
160 baz (int a, int b, int c)
162 foo (!a & (b << c));/* { dg-warning "parentheses" "correct warning" } */
163 foo (!a & (b >> c));/* { dg-warning "parentheses" "correct warning" } */
164 foo (!a & (b + c)); /* { dg-warning "parentheses" "correct warning" } */
165 foo (!a & (b - c)); /* { dg-warning "parentheses" "correct warning" } */
166 foo (!a & (b = c)); /* { dg-warning "parentheses" "correct warning" } */
167 foo (!a & ~b); /* { dg-warning "parentheses" "correct warning" } */
168 foo (!a & (b & c)); /* { dg-warning "parentheses" "correct warning" } */
169 foo (!a & (b | c)); /* { dg-warning "parentheses" "correct warning" } */
170 foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */
171 foo (!a & (2 << c));/* { dg-warning "parentheses" "correct warning" } */
172 foo (!a & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */
173 foo (!a & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */
174 foo (!a & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */
175 foo (!a & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */
176 foo (!a & ~2); /* { dg-warning "parentheses" "correct warning" } */
177 foo (!a & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */
178 foo (!a & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */
179 foo (!1 & (2 << c));/* { dg-warning "parentheses" "correct warning" } */
180 foo (!1 & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */
181 foo (!1 & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */
182 foo (!1 & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */
183 foo (!1 & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */
184 foo (!1 & ~2); /* { dg-warning "parentheses" "correct warning" } */
185 foo (!1 & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */
186 foo (!1 & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */
187 foo (!a | (b << c));/* { dg-warning "parentheses" "correct warning" } */
188 foo (!a | (b >> c));/* { dg-warning "parentheses" "correct warning" } */
189 foo (!a | (b + c)); /* { dg-warning "parentheses" "correct warning" } */
190 foo (!a | (b - c)); /* { dg-warning "parentheses" "correct warning" } */
191 foo (!a | (b = c)); /* { dg-warning "parentheses" "correct warning" } */
192 foo (!a | ~b); /* { dg-warning "parentheses" "correct warning" } */
193 foo (!a | (b & c)); /* { dg-warning "parentheses" "correct warning" } */
194 foo (!a | (b | c)); /* { dg-warning "parentheses" "correct warning" } */
195 foo (!a | (2 << c));/* { dg-warning "parentheses" "correct warning" } */
196 foo (!a | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */
197 foo (!a | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */
198 foo (!a | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */
199 foo (!a | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */
200 foo (!a | ~2); /* { dg-warning "parentheses" "correct warning" } */
201 foo (!a | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */
202 foo (!a | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */
203 foo (!1 | (2 << c));/* { dg-warning "parentheses" "correct warning" } */
204 foo (!1 | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */
205 foo (!1 | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */
206 foo (!1 | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */
207 foo (!1 | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */
208 foo (!1 | ~2); /* { dg-warning "parentheses" "correct warning" } */
209 foo (!1 | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */
210 foo (!1 | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */