-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party
Description
Bugzilla Link | 35319 |
Version | trunk |
OS | Linux |
Reporter | LLVM Bugzilla Contributor |
CC | @dwblaikie,@DougGregor,@rnk,@Weverything |
Fixed by commit(s) | r318456 |
Extended Description
clang version 6.0.0 (trunk 317263)
This code:
int main(int argc, char** argv) {
if (argc > 4); // <-- Note semicolon!
return 0;
}
Gives:
eraseme.cc:2:16: warning: if statement has empty body [-Wempty-body]
if (argc > 4);
^
eraseme.cc:2:16: note: put the semicolon on a separate line to silence this
warning
1 warning generated.
This is good! And it also works for else if
cases. But I just did the same bug and put a semicolon after a bare else:
int main(int argc, char** argv) {
if (argc > 4)
return 1;
else; // <- Semicolon
return 2;
return 0;
}
And there is no warning. This was pretty tricky to find and it seems like the same rule for if
semicolons should just also be applied to else
.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party