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

Alexander Kornienko alexfh at google.com
Wed Jun 25 01:18:21 PDT 2014


Added in r211676.


On Wed, Jun 25, 2014 at 8:52 AM, Richard Smith <richard at metafoo.co.uk>
wrote:

> 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/20140625/ad27bca7/attachment.html>


More information about the cfe-commits mailing list