12178f14cSAlexis Hunt // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough-per-function %s 206caf7d5SAlexander Kornienko 306caf7d5SAlexander Kornienko fallthrough(int n)406caf7d5SAlexander Kornienkoint fallthrough(int n) { 506caf7d5SAlexander Kornienko switch (n / 10) { 606caf7d5SAlexander Kornienko case 0: 706caf7d5SAlexander Kornienko n += 100; 82178f14cSAlexis Hunt case 1: // expected-warning{{unannotated fall-through}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} 906caf7d5SAlexander Kornienko switch (n) { 1006caf7d5SAlexander Kornienko case 111: 1106caf7d5SAlexander Kornienko n += 111; 1206caf7d5SAlexander Kornienko [[clang::fallthrough]]; 1306caf7d5SAlexander Kornienko case 112: 1406caf7d5SAlexander Kornienko n += 112; 152178f14cSAlexis Hunt case 113: // expected-warning{{unannotated fall-through}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} 1606caf7d5SAlexander Kornienko n += 113; 1706caf7d5SAlexander Kornienko break ; 1806caf7d5SAlexander Kornienko } 1906caf7d5SAlexander Kornienko } 2006caf7d5SAlexander Kornienko return n; 2106caf7d5SAlexander Kornienko } 2206caf7d5SAlexander Kornienko fallthrough2(int n)2306caf7d5SAlexander Kornienkoint fallthrough2(int n) { 2406caf7d5SAlexander Kornienko switch (n / 10) { 2506caf7d5SAlexander Kornienko case 0: 2606caf7d5SAlexander Kornienko n += 100; 2706caf7d5SAlexander Kornienko case 1: // no warning, as we didn't "opt-in" for it in this method 2806caf7d5SAlexander Kornienko switch (n) { 2906caf7d5SAlexander Kornienko case 111: 3006caf7d5SAlexander Kornienko n += 111; 3106caf7d5SAlexander Kornienko case 112: // no warning, as we didn't "opt-in" for it in this method 3206caf7d5SAlexander Kornienko n += 112; 3306caf7d5SAlexander Kornienko case 113: // no warning, as we didn't "opt-in" for it in this method 3406caf7d5SAlexander Kornienko n += 113; 3506caf7d5SAlexander Kornienko break ; 3606caf7d5SAlexander Kornienko } 3706caf7d5SAlexander Kornienko } 3806caf7d5SAlexander Kornienko return n; 3906caf7d5SAlexander Kornienko } 40a0e54d45SAlexis Hunt unscoped(int n)41a0e54d45SAlexis Huntvoid unscoped(int n) { 42a0e54d45SAlexis Hunt switch (n % 2) { 43a0e54d45SAlexis Hunt case 0: 44*4f902c7eSRichard Smith [[fallthrough]]; 45*4f902c7eSRichard Smith case 2: 46a0e54d45SAlexis Hunt [[clang::fallthrough]]; 47a0e54d45SAlexis Hunt case 1: 48a0e54d45SAlexis Hunt break; 49a0e54d45SAlexis Hunt } 50a0e54d45SAlexis Hunt } 51