| 1 |
extern int do_stuff (void); |
| 2 |
|
| 3 |
/* Various misleading "while" loops that look like do-whiles due |
| 4 |
to proximity to another clause, but are actually empty. */ |
| 5 |
|
| 6 |
void not_a_do_while_1 (int flag) |
| 7 |
{ |
| 8 |
if (flag) { |
| 9 |
do_stuff (); |
| 10 |
flag = 0; |
| 11 |
} while (flag); // TODO: should we complain here? |
| 12 |
} |
| 13 |
|
| 14 |
void not_a_do_while_2 (int flag) |
| 15 |
{ |
| 16 |
if (!flag) { |
| 17 |
do_stuff (); |
| 18 |
flag = 1; |
| 19 |
} while (flag); // TODO: should we complain here? |
| 20 |
} |
| 21 |
|
| 22 |
void not_a_do_while_3 (int flag) |
| 23 |
{ |
| 24 |
while (!flag) { |
| 25 |
flag = do_stuff (); |
| 26 |
} while (flag); // TODO: should we complain here? |
| 27 |
} |
| 28 |
|
| 29 |
void not_a_do_while_4 (int flag) |
| 30 |
{ |
| 31 |
while (flag) { |
| 32 |
flag = do_stuff (); |
| 33 |
} while (flag); // TODO: should we complain here? |
| 34 |
} |