[PATCH] Fix "warning: fallthrough annotation does not directly precede switch label" in lambdas.
Alexander Kornienko
alexfh at google.com
Tue Jun 24 09:07:57 PDT 2014
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/de412452/attachment.html>
More information about the cfe-commits
mailing list