<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I like this!<div><br></div><div>Out of curiosity, will it be needed for cases like:</div><div><br></div><div>switch (input) {</div><div>case 1: // fallthrough?</div><div>case 2:</div><div> // Handle both 1 and 2</div><div> break;</div><div>default:</div><div> // default</div><div>}</div><div><br></div><div>Thanks,</div><div>~Brady</div><div><br><div><div>On Jan 26, 2014, at 1:41 AM, Joseph Pecoraro <<a href="mailto:pecoraro@apple.com">pecoraro@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello!</div><div><br></div><div>I'm slowly enabling -Wimplicit-fallthrough on projects in the Mac / iOS ports.</div><div><<a href="http://trac.webkit.org/changeset/162793">http://trac.webkit.org/changeset/162793</a>></div><div><<a href="http://clang.llvm.org/docs/LanguageExtensions.html#the-clang-fallthrough-attribute">http://clang.llvm.org/docs/LanguageExtensions.html#the-clang-fallthrough-attribute</a>></div><div><br></div><div>This means that if you write any switch statements with implicit fallthroughs it will produce build errors in projects with the warning enabled.</div><div><br></div><div>If you're writing a switch with a fallthrough, use the "FALLTHROUGH;" annotation (which expands to [[clang::fallthrough]];) to appease the warning.</div><div><br></div><div>The intent of this warning is to catch at compile time any accidental switch fallthroughs, and therefore explicitly annotate everywhere a fallthrough was intended.</div><div><br></div><div>Thanks,</div><div>- JoePeck</div><div><br></div><div>--</div><div><br></div><div>For example. Here is a switch with an implicit fallthrough but no compiler recognized annotation:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>switch (input) {</div><div>case 1:</div><div> output -= 5;</div><div> // fallthrough</div><div>default:</div><div> output += 5;</div><div>}</div></div><div><br></div></blockquote></div><div>When the warning is enabled you will see a build error like:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">main.cpp:9:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]<br> default:<br> ^<br>main.cpp:9:5: note: insert 'FALLTHROUGH;' to silence this warning<br> default:<br> ^<br> FALLTHROUGH; <br>main.cpp:9:5: note: insert 'break;' to avoid fall-through<br> default:<br> ^<br> break; <br><br></blockquote>Use "FALLTHROUGH;" to annotate the fallthrough and build without errors:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>switch (input) {</div><div>case 1:</div><div> output -= 5;</div><div> FALLTHROUGH;</div><div>default:</div><div> output += 5;</div><div>}</div></blockquote></div><div><br></div></div>_______________________________________________<br>webkit-dev mailing list<br><a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>https://lists.webkit.org/mailman/listinfo/webkit-dev<br></blockquote></div><br></div></body></html>