[PATCH] D91895: [Clang] improve -Wimplicit-fallthrough GCC compat

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 18:36:27 PST 2020


rsmith added a comment.

I'd suggest instead of removing these warnings, we split the warning flag in two:

1. A warning flag that warns that there is implicit fallthrough that's not equivalent to `break;` (which sounds like it's what the kernel folks want in the 99% case) -- that is, warn if the language rule "if execution from one case label reaches a case label attached to a different statement, an implicit `break` is evaluated" could give different program behavior.
2. A warning flag that warns that there is implicit fallthrough at all (a superset of (1), and the same as our current warning flag) -- that is, warn if control flow from one case label is able to fall through a case label attached to a different statement.

The linux kernel folks aren't the only users of this facility, and some other users will want an explicit `break;` even before a set of `case` labels that themselves label a `break;`, and will want that enforced by warning. I'd also suggest that we retain our existing warning flag for (2) and add a new warning flag for the subset behavior of (1).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91895/new/

https://reviews.llvm.org/D91895



More information about the cfe-commits mailing list