Added a test to ensure -Wimplicit-fallthrough works with -fblocks correctly.
authorAlexander Kornienko <alexfh@google.com>
Wed, 25 Jun 2014 08:09:35 +0000 (08:09 +0000)
committerAlexander Kornienko <alexfh@google.com>
Wed, 25 Jun 2014 08:09:35 +0000 (08:09 +0000)
llvm-svn: 211676

clang/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp [new file with mode: 0644]

diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp b/clang/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp
new file mode 100644 (file)
index 0000000..9a16f2b
--- /dev/null
@@ -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();
+}