| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-Wparentheses" } |
| 3 |
|
| 4 |
// Template version of Wparentheses-1.C. |
| 5 |
|
| 6 |
int foo (int); |
| 7 |
|
| 8 |
int a, b, c; |
| 9 |
bool d; |
| 10 |
|
| 11 |
template<class T> |
| 12 |
void |
| 13 |
bar (T) |
| 14 |
{ |
| 15 |
if (a = b) // { dg-warning "assignment" "correct warning" } |
| 16 |
foo (0); |
| 17 |
if ((a = b)) |
| 18 |
foo (1); |
| 19 |
if (a = a) // { dg-warning "assignment" "correct warning" } |
| 20 |
foo (2); |
| 21 |
if ((a = a)) |
| 22 |
foo (3); |
| 23 |
if (b = c) // { dg-warning "assignment" "correct warning" } |
| 24 |
foo (4); |
| 25 |
else |
| 26 |
foo (5); |
| 27 |
if ((b = c)) |
| 28 |
foo (6); |
| 29 |
else |
| 30 |
foo (7); |
| 31 |
if (b = b) // { dg-warning "assignment" "correct warning" } |
| 32 |
foo (8); |
| 33 |
else |
| 34 |
foo (9); |
| 35 |
if ((b = b)) |
| 36 |
foo (10); |
| 37 |
else |
| 38 |
foo (11); |
| 39 |
while (c = b) // { dg-warning "assignment" "correct warning" } |
| 40 |
foo (12); |
| 41 |
while ((c = b)) |
| 42 |
foo (13); |
| 43 |
while (c = c) // { dg-warning "assignment" "correct warning" } |
| 44 |
foo (14); |
| 45 |
while ((c = c)) |
| 46 |
foo (15); |
| 47 |
do foo (16); while (a = b); // { dg-warning "assignment" "correct warning" } |
| 48 |
do foo (17); while ((a = b)); |
| 49 |
do foo (18); while (a = a); // { dg-warning "assignment" "correct warning" } |
| 50 |
do foo (19); while ((a = a)); |
| 51 |
for (;c = b;) // { dg-warning "assignment" "correct warning" } |
| 52 |
foo (20); |
| 53 |
for (;(c = b);) |
| 54 |
foo (21); |
| 55 |
for (;c = c;) // { dg-warning "assignment" "correct warning" } |
| 56 |
foo (22); |
| 57 |
for (;(c = c);) |
| 58 |
foo (23); |
| 59 |
d = a = b; // { dg-warning "assignment" "correct warning" } |
| 60 |
foo (24); |
| 61 |
d = (a = b); |
| 62 |
foo (25); |
| 63 |
d = a = a; // { dg-warning "assignment" "correct warning" } |
| 64 |
foo (26); |
| 65 |
d = (a = a); |
| 66 |
foo (27); |
| 67 |
} |