r178543 - Fixed "fallthrough annotation does not directly precede switch label" warning in
Alexander Kornienko
alexfh at google.com
Tue Apr 2 08:20:32 PDT 2013
Author: alexfh
Date: Tue Apr 2 10:20:32 2013
New Revision: 178543
URL: http://llvm.org/viewvc/llvm-project?rev=178543&view=rev
Log:
Fixed "fallthrough annotation does not directly precede switch label" warning in
case when [[clang::fallthrough]]; is used in a method of a local class.
Added:
cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=178543&r1=178542&r2=178543&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Apr 2 10:20:32 2013
@@ -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) {
Added: cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp?rev=178543&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp (added)
+++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-regression.cpp Tue Apr 2 10:20:32 2013
@@ -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;
+ }
+ }
+ };
+}
+
More information about the cfe-commits
mailing list