[PATCH] Fix "warning: fallthrough annotation does not directly precede switch label" in lambdas.

Richard Smith richard at metafoo.co.uk
Tue Jun 24 23:52:49 PDT 2014


Yes, the extra test would be good. Thanks!
On 24 Jun 2014 18:08, "Alexander Kornienko" <alexfh at google.com> wrote:

> On Tue, Jun 24, 2014 at 4:43 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>
>> LGTM
>>
>> If blocks also need a fix, feel free to do that in a later patch :)
>>
>
> Oh, you're right, I didn't think about blocks. For some reason bodies of
> blocks are not duplicated in the AST, as it is with lambdas, so the warning
> works fine with them. If you want, I can add a test for this:
>
> $ cat test/SemaCXX/switch-implicit-fallthrough-blocks.cpp
> // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 -Wimplicit-fallthrough %s
>
> void fallthrough_in_blocks() {
>   void (^block)() = ^{
>     int x = 0;
>     switch (x) {
>     case 0:
>       x++;
>       [[clang::fallthrough]]; // no diagnostics
>     case 1:
>       x++;
>     default: // \
>         expected-warning{{unannotated fall-through between switch labels}} \
>         expected-note{{insert 'break;' to avoid fall-through}}
>       break;
>     }
>   };
>   block();
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140624/9b1cbb82/attachment.html>


More information about the cfe-commits mailing list