diff options
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/switch-implicit-fallthrough-regression.cpp | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 9993b48832..00d3c47525 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -817,6 +817,10 @@ namespace { return true; } + // We don't want to traverse local type declarations. We analyze their + // methods separately. + bool TraverseDecl(Decl *D) { return true; } + private: static const AttributedStmt *asFallThroughAttr(const Stmt *S) { diff --git a/test/SemaCXX/switch-implicit-fallthrough-regression.cpp b/test/SemaCXX/switch-implicit-fallthrough-regression.cpp new file mode 100644 index 0000000000..aec3769e00 --- /dev/null +++ b/test/SemaCXX/switch-implicit-fallthrough-regression.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s + +void f() { + class C { + void f(int x) { + switch (x) { + case 0: + x++; + [[clang::fallthrough]]; // expected-no-diagnostics + case 1: + x++; + break; + } + } + }; +} + |