<div>Hi all,</div><div><br></div><div>I'm reposting this message, as it seems to be lost. It would be really nice if someone could take a look at llvm changes and find out if they relate to real bugs or not. I would also appreciate to hear opinions on the suggested LLVM_FALLTHROUGH macro as a compiler-verifiable way to annotate fall-throughs in switch statements.</div>
<div><br></div><div>Thank you!</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I compiled llvm and clang with the recently added <font face="courier new, monospace">-Wimplicit-fallthrough</font> diagnostic and analyzed the results. For those who are curious: there are about 400 'unannotated fall-through' warnings in total, about 290 fall-through locations are annotated in comments, about 30 locations fall-through to an empty block (case 1: ....<no break>  case 2: break;), 7 locations have <font face="courier new, monospace">assert(false)</font> not followed by <font face="courier new, monospace">break;</font><br>
>From the remaining ~70 locations 6 look like real bugs. I've prepared two patches: for llvm and clang, which add <font face="courier new, monospace">break;</font> for all these locations. I've also removed two unnecessary fall-throughs in headers to reduce total amount of 'unannotated fall-through' warning messages. <br>
I can't guarantee that all these 6 locations are real bugs, but they look very much like unintended fall-throughs.<br>Could you, please, review this patch?<br>Thanks!<br>P.S. It would also be interesting to know what people think about converting fall-through annotations in comments to a checked annotation so we could use this diagnostic on regular basis?<br>
We could wrap [[clang::fallthrough]] to a macro, so the code would continue to work in c++98 mode, but in c++11 mode it would also allow to run this diagnostic (btw, is llvm compilable in c++11 mode?). Sample implementation of macro:<br>
<b>#ifdef __clang__<br></b><b>#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")<br></b><b>#define LLVM_FALLTHROUGH [[clang::fallthrough]]<br></b><b>#endif<br></b><b>#endif<br></b><b>
</b><b>#ifndef LLVM_FALLTHROUGH<br></b><b>#define LLVM_FALLTHROUGH do { } while (0)<br></b><b>#endif</b></blockquote></div><div><br></div><div><br></div>-- 
<div>Regards,</div><div>Alexander Kornienko</div>