<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56452>56452</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Possible false positive -Wempty-body when indented semicolon after statement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
arurke
</td>
</tr>
</table>
<pre>
Clang-14 with -Wall will raise a -Wempty-body warning if there is an indented `;` after a if or while-statement:
```
while(1);
;
```
```
<source>:6:13: warning: while loop has empty body [-Wempty-body]
while(1);
^
<source>:6:13: note: put the semicolon on a separate line to silence this warning
```
This becomes annoying in use-cases where defines are used to exclude functions:
```
/* foo.h */
#if OPT_FUNC_NEEDED
void optional_function();
#else
#define optional_function()
#endif
/* bar.c */
#include "foo.h"
void raising_warning(void) {
while(1);
optional_function(); // Raises -Wempty-body when !OPT_FUNC_NEEDED
// The call above is equivalent to the following
// ;
}
```
MWE: https://godbolt.org/z/oG7nqPa8d
Is this a false positive, or intended behavior?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVEtz2yAQ_jXosmOPXrasgw6JH50emmY66eToQQJZtBgUQHbTX98Fx4-4TquREAsL--23j1qz12ouqdqMkhz2wnUweqZS4hQHQ4XlQHGJb3v3OqpRG_bUKKE2IFpwHTcchAWqQCjGleMMyDQm2T2OQFvHDR5HTW1g3wnJR9ZRx7eoSbI7Ei9IfOf1D28QgxpJZwlJS39PWAR8TsLVgWsxm1s9mIaTbIk2pvglGQ5H3GHqbYDUuoeOWgjOQXCOTO4vnSWTxRnAh8iOD5ks_4NBacf9vx-cJw8s34pGS60AX4piTw3yA1IoDk6DRYuqwWmHJB8duOX1k1eoeaO33EdD6dcQIgWD5aOGWlzdh2Ax3uLdqINz3GPeCv_VyIFxaAfVOKGVPcfmJsPpiqR30Go97gBnXn7byDDUXx-f1qvvD_P1w3K5WL7xt9OCge797VSuj4aQzEsu8TyXlp-EA9YPj53OKCbad3gPAGtqxs1fANXBV5KmwQH8XyD0CY_ErY9UpzO_jMaAFPeXJv6ZDx_7CQHaCr75wrJXddVxhfvJTf4uyuBwwxNmT-MLldZ6F2qQvwxiRzFfnI-pz65WS6n3p5S5OH39nENQLG7G_MuzT2TonOtDdoRrNprVWrqxNsjU6jd--lOhXh7pjF2i_mwP-UuhpRhe6LUVTuyQurnvCwK7BvYOhunb0Z3QhmSriFUZK7OSRk44yatHba2osWbf33CDwFMbOpfWoQ2dGk80GFldOYJ9b6jHWD0oSLk7_ka90T9441AU1g7c4mQyzSdp1FUFbeoiT0vWsiKri2nO2WyalpMEZZ7QWSRpjdlcYUfBLhKJKo3TNC7iMkknZZaP87ZM8mmc5kVbFDWrSR7zLRVy7A17SiNTBQz1sLG4KYV19rxJkZCN4vx4Px1cp01FzWB-8iigrQLUP9zXwm0">