| Issue |
56452
|
| Summary |
Possible false positive -Wempty-body when indented semicolon after statement
|
| Labels |
|
| Assignees |
|
| Reporter |
arurke
|
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?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs