From Jason Turner

[dcl.attr.fallthrough]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvu9t18jo/{from.md → to.md} +40 -0
tmp/tmpvu9t18jo/{from.md → to.md} RENAMED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Fallthrough attribute <a id="dcl.attr.fallthrough">[[dcl.attr.fallthrough]]</a>
2
+
3
+ The *attribute-token* `fallthrough` may be applied to a null statement (
4
+ [[stmt.expr]]); such a statement is a fallthrough statement. The
5
+ *attribute-token* `fallthrough` shall appear at most once in each
6
+ *attribute-list* and no *attribute-argument-clause* shall be present. A
7
+ fallthrough statement may only appear within an enclosing `switch`
8
+ statement ([[stmt.switch]]). The next statement that would be executed
9
+ after a fallthrough statement shall be a labeled statement whose label
10
+ is a case label or default label for the same `switch` statement. The
11
+ program is ill-formed if there is no such statement.
12
+
13
+ [*Note 1*: The use of a fallthrough statement is intended to suppress a
14
+ warning that an implementation might otherwise issue for a case or
15
+ default label that is reachable from another case or default label along
16
+ some path of execution. Implementations are encouraged to issue a
17
+ warning if a fallthrough statement is not dynamically
18
+ reachable. — *end note*]
19
+
20
+ [*Example 1*:
21
+
22
+ ``` cpp
23
+ void f(int n) {
24
+ void g(), h(), i();
25
+ switch (n) {
26
+ case 1:
27
+ case 2:
28
+ g();
29
+ [[fallthrough]];
30
+ case 3: // warning on fallthrough discouraged
31
+ h();
32
+ case 4: // implementation may warn on fallthrough
33
+ i();
34
+ [[fallthrough]]; // ill-formed
35
+ }
36
+ }
37
+ ```
38
+
39
+ — *end example*]
40
+