For MSVC compatibility, based on request in https://bugs.llvm.org/show_bug.cgi?id=4546.
Details
Diff Detail
Event Timeline
lib/Sema/SemaStmt.cpp | ||
---|---|---|
869 | TODO: if (!SC) -> switch has no default and case labels (empty body is misleading.. switch(x) x = b) switch (x) { // warn_empty_switch_body } |
^ not yet landed, but please @aaron.ballman take a look, this patch is ready for review.
I'm wary of adding this as an on-by-default warning, despite its presence in MSVC (and despite submitting a similar patch years ago to implement the same functionality). Machine-generated code runs into this one frequently (we've been bitten by it numerous times with our tablegen code, especially in the backends), but it does not seem likely to occur in hand-written code very often.
While it's pretty easy to implement this in the frontend, I sort of feel like this is a better candidate for clang-tidy's readability module.
I have a hunch that this will be equally as trivially implementable in clang-tidy -- if you go that route, feel free to add me as a reviewer!
TODO:
if (!SC) -> switch has no default and case labels (empty body is misleading.. switch(x) x = b)
switch (x) {
}