Clang Project

clang_source_code/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 -Wimplicit-fallthrough %s
2
3void fallthrough_in_blocks() {
4  void (^block)() = ^{
5    int x = 0;
6    switch (x) {
7    case 0:
8      x++;
9      [[clang::fallthrough]]; // no diagnostics
10    case 1:
11      x++;
12    default: // \
13        expected-warning{{unannotated fall-through between switch labels}} \
14        expected-note{{insert 'break;' to avoid fall-through}}
15      break;
16    }
17  };
18  block();
19}
20