Hi Chandler,<br><br><div class="gmail_quote">On Thu, Apr 26, 2012 at 1:02 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com">chandlerc@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 class="gmail_extra"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><font face="courier new, monospace"><br>
test.cpp:16:5: note: insert [[fallthrough]]; to silence this warning [-Wimplicit-fallthrough]</font></div></div></blockquote>
<div><br></div></div><div>s/to silence this warning/to annotate the fall-through as intentional/ ?</div></div></div></blockquote><div>I found it quite common in clang to use "to silence this warning" wording in fix-it hints. As for me, it seems to be a good idea to have a common wording for fix-it hints which leave semantic as is and just serve to shut up the relevant diagnostic message. Or you see a reason to have a specific message in this particular case?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra"><div class="gmail_quote"><div> * added specific diagnostic message for unreachable fall-through annotation, e.g. this code:</div>

</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><font face="courier new, monospace">switch(x) {</font></div></div></div><div class="gmail_extra">


<div class="gmail_quote"><div><font face="courier new, monospace">case 1:</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="courier new, monospace">  break;</font></div></div></div>


<div class="gmail_extra"><div class="gmail_quote"><div><font face="courier new, monospace">  [[fallthrough]];</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="courier new, monospace">case 2:</font></div>


</div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="courier new, monospace">...</font></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div>will produce a similar warning:</div>


<div><div><font face="courier new, monospace">test.cpp:12:7: warning: fallthrough annotation in unreachable code [-Wimplicit-fallthrough]</font></div><div><font face="courier new, monospace">      [[fallthrough]];</font></div>


<div><font face="courier new, monospace">      ^</font></div></div></div></div></blockquote><div><br></div></div><div>Idea for a future iteration: add a note that points to the break here, at least in the easy cases. We should be able to find the terminator of the CFG block which precedes this somehow.</div>
</div></div></blockquote><div>The whole point is that CFG block containing break statement doesn't precede a block with a code just after the break.</div><div>BTW, current logic detects only trivially unreachable code, but if a part of unreachable code contains branches/loops/etc, so it will treat it as a fall-through (either annotated or not). </div>
<div><br></div><div>-- </div><div>Best regards,</div><div>Alexander Kornienko</div></div>