]> granicus.if.org Git - clang/commitdiff
Moving the documentation for the clang::fallthrough attribute into AttrDocs.
authorAaron Ballman <aaron@aaronballman.com>
Wed, 19 Feb 2014 20:56:51 +0000 (20:56 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 19 Feb 2014 20:56:51 +0000 (20:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201715 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LanguageExtensions.rst
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td

index 25ed9f8610fb7f6a102cb17d390120afbc8fccd1..15bad2da3c140b7114f6e34ef2fed0d2dcfcea2f 100644 (file)
@@ -1570,51 +1570,6 @@ Non-standard C++11 Attributes
 Clang's non-standard C++11 attributes live in the ``clang`` attribute
 namespace.
 
-The ``clang::fallthrough`` attribute
-------------------------------------
-
-The ``clang::fallthrough`` attribute is used along with the
-``-Wimplicit-fallthrough`` argument to annotate intentional fall-through
-between switch labels.  It can only be applied to a null statement placed at a
-point of execution between any statement and the next switch label.  It is
-common to mark these places with a specific comment, but this attribute is
-meant to replace comments with a more strict annotation, which can be checked
-by the compiler.  This attribute doesn't change semantics of the code and can
-be used wherever an intended fall-through occurs.  It is designed to mimic
-control-flow statements like ``break;``, so it can be placed in most places
-where ``break;`` can, but only if there are no statements on the execution path
-between it and the next switch label.
-
-Here is an example:
-
-.. code-block:: c++
-
-  // compile with -Wimplicit-fallthrough
-  switch (n) {
-  case 22:
-  case 33:  // no warning: no statements between case labels
-    f();
-  case 44:  // warning: unannotated fall-through
-    g();
-    [[clang::fallthrough]];
-  case 55:  // no warning
-    if (x) {
-      h();
-      break;
-    }
-    else {
-      i();
-      [[clang::fallthrough]];
-    }
-  case 66:  // no warning
-    p();
-    [[clang::fallthrough]]; // warning: fallthrough annotation does not
-                            //          directly precede case label
-    q();
-  case 77:  // warning: unannotated fall-through
-    r();
-  }
-
 ``gnu::`` attributes
 --------------------
 
index 673b4806041f333ebd27769463ca3eb9b3a0ae6a..0a38bd61ec6bdc2bd75d6698e4be89a166850983 100644 (file)
@@ -642,7 +642,7 @@ def ExtVectorType : Attr {
 def FallThrough : Attr {
   let Spellings = [CXX11<"clang", "fallthrough">];
 //  let Subjects = [NullStmt];
-  let Documentation = [Undocumented];
+  let Documentation = [FallthroughDocs];
 }
 
 def FastCall : InheritableAttr {
index 37b61fdc228906292d7f1a626d5ee511323963c8..70d6e14e055fb376d2578617a22237ff7a01c1c2 100644 (file)
@@ -410,3 +410,50 @@ When one method overrides another, the overriding method can be more widely avai
   @end
   }];
 }
+
+def FallthroughDocs : Documentation {
+  let Category = DocCatStmt;
+  let Content = [{
+The ``clang::fallthrough`` attribute is used along with the
+``-Wimplicit-fallthrough`` argument to annotate intentional fall-through
+between switch labels.  It can only be applied to a null statement placed at a
+point of execution between any statement and the next switch label.  It is
+common to mark these places with a specific comment, but this attribute is
+meant to replace comments with a more strict annotation, which can be checked
+by the compiler.  This attribute doesn't change semantics of the code and can
+be used wherever an intended fall-through occurs.  It is designed to mimic
+control-flow statements like ``break;``, so it can be placed in most places
+where ``break;`` can, but only if there are no statements on the execution path
+between it and the next switch label.
+
+Here is an example:
+
+.. code-block:: c++
+
+  // compile with -Wimplicit-fallthrough
+  switch (n) {
+  case 22:
+  case 33:  // no warning: no statements between case labels
+    f();
+  case 44:  // warning: unannotated fall-through
+    g();
+    [[clang::fallthrough]];
+  case 55:  // no warning
+    if (x) {
+      h();
+      break;
+    }
+    else {
+      i();
+      [[clang::fallthrough]];
+    }
+  case 66:  // no warning
+    p();
+    [[clang::fallthrough]]; // warning: fallthrough annotation does not
+                            //          directly precede case label
+    q();
+  case 77:  // warning: unannotated fall-through
+    r();
+  }
+  }];
+}