[cfe-commits] [PATCH] Implicit fall-through between switch labels

Alexander Kornienko alexfh at google.com
Wed Apr 25 14:08:49 PDT 2012


Hi,

On Wed, Apr 25, 2012 at 6:12 PM, Alexander Kornienko <alexfh at google.com>wrote:

> The new version of patch addresses most of the issues discussed here +
> refactored code ;)
>

More specifically, changes in this version of patch:
 * diagnostic message reworded; each warning is accompanied by exactly one
note with a fix-it hint, for simplicity and consistency the location to
insert fall-through annotation is always immediately before the relevant
case label:
test.cpp:16:5: warning: unannotated fall-through between switch labels
[-Wimplicit-fallthrough]
    case 13:
    ^
test.cpp:16:5: note: insert [[fallthrough]]; to silence this warning
[-Wimplicit-fallthrough]
    case 13:
    ^
    [[fallthrough]];
 * added specific diagnostic message for unreachable fall-through
annotation, e.g. this code:

switch(x) {
case 1:
  break;
  [[fallthrough]];
case 2:
...

will produce a similar warning:
test.cpp:12:7: warning: fallthrough annotation in unreachable code
[-Wimplicit-fallthrough]
      [[fallthrough]];
      ^
There are also a couple of ideas from Jordy Rose, which I would like to
implement, but didn't have time yet.

-- 
Best regards,
Alexander Kornienko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120425/1ae0e7fc/attachment.html>


More information about the cfe-commits mailing list