[dcl.attr.fallthrough] (original) (raw)
9 Declarations [dcl]
9.13 Attributes [dcl.attr]
9.13.5 Fallthrough attribute [dcl.attr.fallthrough]
A fallthrough statement may only appear within an enclosing switch statement ([stmt.switch]).
The next statement that would be executed after a fallthrough statement shall be a labeled statement whose label is a case label or default label for the same switch statement and, if the fallthrough statement is contained in an iteration statement, the next statement shall be part of the same execution of the substatement of the innermost enclosing iteration statement.
The program is ill-formed if there is no such statement.
Recommended practice: The use of a fallthrough statement should suppress a warning that an implementation might otherwise issue for a case or default label that is reachable from another case or default label along some path of execution.
The value of a has-attribute-expression for the fallthrough attribute should be 0if the attribute does not cause suppression of such warnings.
Implementations should issue a warning if a fallthrough statement is not dynamically reachable.
[Example 1: void f(int n) { void g(), h(), i();switch (n) { case 1: case 2: g();[[fallthrough]];case 3: do { [[fallthrough]]; } while (false);case 6: do { [[fallthrough]]; } while (n--);case 7: while (false) { [[fallthrough]]; } case 5: h();case 4: i();[[fallthrough]]; } } — _end example_]