]> granicus.if.org Git - clang/commitdiff
Fixed "fallthrough annotation does not directly precede switch label" warning in
authorAlexander Kornienko <alexfh@google.com>
Tue, 2 Apr 2013 15:20:32 +0000 (15:20 +0000)
committerAlexander Kornienko <alexfh@google.com>
Tue, 2 Apr 2013 15:20:32 +0000 (15:20 +0000)
case when [[clang::fallthrough]]; is used in a method of a local class.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178543 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/AnalysisBasedWarnings.cpp
test/SemaCXX/switch-implicit-fallthrough-regression.cpp [new file with mode: 0644]

index 9993b488322dd70f1b4450e5f0ad460641973edd..00d3c47525d31f6ed98f3e19310308c85ebc2c61 100644 (file)
@@ -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 (file)
index 0000000..aec3769
--- /dev/null
@@ -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;
+      }
+    }
+  };
+}
+