Any thoughts on these patches/proposals?<br><br><div class="gmail_quote">On Mon, Jun 4, 2012 at 9:24 PM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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"><div class="im">
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></div><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><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div>-- 
<div>Regards,</div><div>Alexander Kornienko</div>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div><font color="#666666"><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(213,15,37);border-right-color:rgb(213,15,37);border-bottom-color:rgb(213,15,37);border-left-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Alexander Kornienko |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(51,105,232);border-right-color:rgb(51,105,232);border-bottom-color:rgb(51,105,232);border-left-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Software Engineer |</span></font><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(0,153,57);border-right-color:rgb(0,153,57);border-bottom-color:rgb(0,153,57);border-left-color:rgb(0,153,57);padding-top:2px;margin-top:2px"><font color="#666666"> </font><a href="mailto:alexfh@google.com" style="color:rgb(17,85,204)" target="_blank">alexfh@google.com</a> |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(238,178,17);border-right-color:rgb(238,178,17);border-bottom-color:rgb(238,178,17);border-left-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a value="+35315435283" style="color:rgb(17,85,204)">+49 151 221 77 957</a></span></div>
</div><div><font color="#666666"><span style="background-color:rgb(255,255,255);font-family:Arial,Verdana,sans-serif">Google Germany GmbH | </span><span style="background-color:rgb(255,255,255);font-family:Arial,Verdana,sans-serif">Dienerstr. 12 | </span><span style="background-color:rgb(255,255,255);font-family:Arial,Verdana,sans-serif">80331 München</span></font></div>
<br>