diff options
| author | Alexander Kornienko <alexfh@google.com> | 2013-04-02 15:20:32 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2013-04-02 15:20:32 +0000 |
| commit | a9c809f75d68dbdbd530f6b095a7b17d2455d256 (patch) | |
| tree | f396f248a390b2e57854151f443e5212850aa89a | |
| parent | c238c87e1292d54c25d0570165d0a7d0ca8ea9e1 (diff) | |
| download | bcm5719-llvm-a9c809f75d68dbdbd530f6b095a7b17d2455d256.tar.gz bcm5719-llvm-a9c809f75d68dbdbd530f6b095a7b17d2455d256.zip | |
Fixed "fallthrough annotation does not directly precede switch label" warning in
case when [[clang::fallthrough]]; is used in a method of a local class.
llvm-svn: 178543
| -rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/switch-implicit-fallthrough-regression.cpp | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 9993b488322..00d3c47525d 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/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/clang/test/SemaCXX/switch-implicit-fallthrough-regression.cpp b/clang/test/SemaCXX/switch-implicit-fallthrough-regression.cpp new file mode 100644 index 00000000000..aec3769e00e --- /dev/null +++ b/clang/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; + } + } + }; +} + |

