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

Chandler Carruth chandlerc at google.com
Wed Apr 25 16:02:16 PDT 2012


Thanks for the awesome update. A few tiny comments inline.

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

> 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]
>

s/to silence this warning/to annotate the fall-through as intentional/ ?


>     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]];
>       ^
>

Idea for a future iteration: add a note that points to the break here, at
least in the easy cases. We should be able to find the terminator of the
CFG block which precedes this somehow.


More comments on your other email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120425/89a94f80/attachment.html>


More information about the cfe-commits mailing list