tmp/tmphgd_jz32/{from.md → to.md}
RENAMED
|
@@ -1,23 +1,25 @@
|
|
| 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]]
|
| 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
|
| 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
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
warning that an implementation might otherwise issue for a
|
| 15 |
-
default label that is reachable from another case or default
|
| 16 |
-
some path of execution. Implementations
|
| 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) {
|
|
@@ -26,14 +28,26 @@ void f(int 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]]; //
|
| 35 |
}
|
| 36 |
}
|
| 37 |
```
|
| 38 |
|
| 39 |
— *end example*]
|
|
|
|
| 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 and, if
|
| 11 |
+
the fallthrough statement is contained in an iteration statement, the
|
| 12 |
+
next statement shall be part of the same execution of the substatement
|
| 13 |
+
of the innermost enclosing iteration statement. The program is
|
| 14 |
+
ill-formed if there is no such statement.
|
| 15 |
|
| 16 |
+
*Recommended practice:* The use of a fallthrough statement should
|
| 17 |
+
suppress a warning that an implementation might otherwise issue for a
|
| 18 |
+
case or default label that is reachable from another case or default
|
| 19 |
+
label along some path of execution. Implementations should issue a
|
| 20 |
+
warning if a fallthrough statement is not dynamically reachable.
|
|
|
|
| 21 |
|
| 22 |
[*Example 1*:
|
| 23 |
|
| 24 |
``` cpp
|
| 25 |
void f(int n) {
|
|
|
|
| 28 |
case 1:
|
| 29 |
case 2:
|
| 30 |
g();
|
| 31 |
[[fallthrough]];
|
| 32 |
case 3: // warning on fallthrough discouraged
|
| 33 |
+
do {
|
| 34 |
+
[[fallthrough]]; // error: next statement is not part of the same substatement execution
|
| 35 |
+
} while (false);
|
| 36 |
+
case 6:
|
| 37 |
+
do {
|
| 38 |
+
[[fallthrough]]; // error: next statement is not part of the same substatement execution
|
| 39 |
+
} while (n--);
|
| 40 |
+
case 7:
|
| 41 |
+
while (false) {
|
| 42 |
+
[[fallthrough]]; // error: next statement is not part of the same substatement execution
|
| 43 |
+
}
|
| 44 |
+
case 5:
|
| 45 |
h();
|
| 46 |
case 4: // implementation may warn on fallthrough
|
| 47 |
i();
|
| 48 |
+
[[fallthrough]]; // error
|
| 49 |
}
|
| 50 |
}
|
| 51 |
```
|
| 52 |
|
| 53 |
— *end example*]
|