[PATCH] D91895: [Clang] avoid -Wimplicit-fallthrough for fallthrough to break

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 20 14:44:04 PST 2020


nickdesaulniers created this revision.
nickdesaulniers added reviewers: rsmith, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nickdesaulniers requested review of this revision.

Clang differs slightly than GCC for the pattern:

switch (x) {

  case 0:
    ++x;
  default:
    break;

}

Clang will warn, GCC will not.  This is making it excessively painful to
enable -Wimplicit-fallthrough for Linux kernel builds with Clang, see
below link in which 140 patches were sent to try to fix up these
differences in kernel code. Kernel and GCC developers point out that
Clang should not warn in this case.

Link: https://github.com/ClangBuiltLinux/linux/issues/636
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
Link: https://lore.kernel.org/lkml/CANiq72=E_gEVvqUUTSqU4zegC2=yZSTM4b=4G-iofp6d3=UgWQ@mail.gmail.com/T/#t
Signed-off-by: Nick Desaulniers <ndesaulniers at google.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91895

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91895.306785.patch
Type: text/x-patch
Size: 3979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201120/c3d3f2e9/attachment-0001.bin>


More information about the cfe-commits mailing list