From: Alexander Kornienko Date: Wed, 25 Jun 2014 08:09:35 +0000 (+0000) Subject: Added a test to ensure -Wimplicit-fallthrough works with -fblocks correctly. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f074fb6303750e5405d0192115cc53aeca3e262;p=clang Added a test to ensure -Wimplicit-fallthrough works with -fblocks correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211676 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp b/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp new file mode 100644 index 0000000000..9a16f2b4b4 --- /dev/null +++ b/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp @@ -0,0 +1,19 @@ +// 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(); +}