Open llvmbot opened 5 years ago
Yes, -Wextra-semi and -Wextra-semi-stmt are two different warnings that fire on different cases. -Wextra-semi catches extra semicolons outside of a function, where they are an error in some language modes (but Clang accepts them as an extension). -Wextra-semi-stmt catches empty statements in compound-statements, which is valid in all language modes, but usually unintentional (though harmless).
Having different warning flags for different situations is intentional, but for historical reasons -Wextra-semi catches just the declaration case. We could reconsider that (maybe rename -Wextra-semi to -Wextra-semi-decl and make -Wextra-semi cover both -Wextra-semi-decl and -Wextra-semi-stmt).
Extended Description
Clang does not warn to remove the empty expression statement with the warning flag [-Wextra-semi].
For the following example, Clang does not warn to remove the empty expression statement with the warning flag [-Wextra-semi]. $ cat s.c int main() { int a = 0; ; return 0; }
$ clang --version clang version 7.0.0 (tags/RELEASE_700/final) Target: x86_64-unknown-linux-gnu Thread model: posix
$ clang -Wextra-semi s.c No warning generated.
Under the same workstation: $ clang-8.0 --Wextra-semi-stmt s.c s.c:4:5: warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt] ; ^ 1 warning generated.