<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Alex Kornienko proposed enabling this warning back in 2012 here:<br></div><div><a href="http://lists.llvm.org/pipermail/llvm-dev/2012-July/051386.html">http://lists.llvm.org/pipermail/llvm-dev/2012-July/051386.html</a></div><div><br></div><div>At the time, Chris Lattner said he didn't feel it was worth annotating</div><div>all of LLVM and Clang with a new macro to enable this warning.</div><div><br></div><div>However, GCC 7 added this warning as part of -Wextra, and we've slowly</div><div>annotated most of LLVM and Clang with LLVM_FALLTHROUGH.</div><div><br></div><div>At this point, I think we should re-evaluate this decision and enable</div><div>this warning for both clang and GCC.</div><div><br></div><div>Since our codebase is already annotated, it will help developers (like</div><div>me), who use Clang locally, to find unintended fallthrough bugs in their</div><div>code. For example, I committed r345676, which had to be reverted because</div><div>of an unintended fallthrough. This warning would've helped.</div><div><br></div><div>There is also marginal benefit to aligning warnings between GCC and</div><div>Clang. While there will always be divergence in warnings between GCC and</div><div>Clang, when possible, it saves time when clang can diagnose things that</div><div>would later become a -Werror warning on some GCC 7 buildbot.</div><div><br></div><div>This is a summary of differences in the behavior of</div><div>-Wimplicit-fallthrough between clang and GCC:</div><div>1. GCC recognizes comments that say "fall through" as annotations, clang</div><div>   doesn't</div><div>2. GCC doesn't warn on "case N: foo(); default: break;", clang does</div><div>3. GCC doesn't warn when the case contains a switch, but falls through</div><div>   the outer case. See the AArch64ISelLowering.cpp change for an</div><div>   instance where this almost caused a bug, but a redundant check saved</div><div>   us. I've removed the redundant check.</div><div>4. Clang warns on LLVM_FALLTHROUGH after llvm_unreachable. GCC doesn't,</div><div>   so I removed the one instance of this that I found.</div><div><br></div><div>Changing Clang's behavior in light of these differences is out of scope</div><div>for me. I want developers who compile with any of the last 4 years of</div><div>clang releases to be able to use this warning, and those releases have</div><div>the behavior described above. If you want to discuss changing Clang to</div><div>be more like GCC here, please file a bug or start a thread on cfe-dev.</div><div><br></div><div>I posted a patch with the this RFC as the commit message here so you can see what this looks like now:</div><div><a href="https://reviews.llvm.org/D53950">https://reviews.llvm.org/D53950</a><br></div><div><br>To summarize, this warning is already enabled for GCC and</div><div>we've already annotated most of our codebase for it, so let's enable the</div><div>warning for clang.</div></div></div></div>