Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wparentheses-2.C

raw
1 // Test operation of -Wparentheses. Warnings for assignments used as
2 // truth-values shouldn't apply other than for plain assignment.
3 // Essentially the same as gcc.dg/Wparentheses-10.c.
4 // Origin: Joseph Myers <[email protected]>
5
6 // { dg-do compile }
7 // { dg-options "-Wparentheses" }
8
9 int foo (int);
10
11 int a, b, c;
12 bool d;
13
14 void
15 bar (void)
16 {
17 if (a += b)
18 foo (0);
19 if (a -= a)
20 foo (1);
21 if (b *= c)
22 foo (2);
23 else
24 foo (3);
25 if (b /= b)
26 foo (4);
27 else
28 foo (5);
29 while (c %= b)
30 foo (6);
31 while (c <<= c)
32 foo (7);
33 do foo (8); while (a >>= b);
34 do foo (9); while (a &= a);
35 for (;c ^= b;)
36 foo (10);
37 for (;c |= c;)
38 foo (11);
39 d = a += b;
40 foo (12);
41 d = a -= a;
42 foo (13);
43 }