Init
This commit is contained in:
49
cppdraft/dcl/attr/fallthrough.md
Normal file
49
cppdraft/dcl/attr/fallthrough.md
Normal file
@@ -0,0 +1,49 @@
|
||||
[dcl.attr.fallthrough]
|
||||
|
||||
# 9 Declarations [[dcl]](./#dcl)
|
||||
|
||||
## 9.13 Attributes [[dcl.attr]](dcl.attr#fallthrough)
|
||||
|
||||
### 9.13.5 Fallthrough attribute [dcl.attr.fallthrough]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9773)
|
||||
|
||||
The [*attribute-token*](dcl.attr.grammar#nt:attribute-token "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") fallthrough may be applied to a [null statement](stmt.expr#def:statement,null "8.3 Expression statement [stmt.expr]"); such a statement is a fallthrough statement[.](#1.sentence-1)
|
||||
|
||||
No [*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") shall be present[.](#1.sentence-2)
|
||||
|
||||
A fallthrough statement may only appear within
|
||||
an enclosing switch statement ([[stmt.switch]](stmt.switch "8.5.3 The switch statement"))[.](#1.sentence-3)
|
||||
|
||||
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[.](#1.sentence-4)
|
||||
|
||||
The program is ill-formed if there is no such statement[.](#1.sentence-5)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9789)
|
||||
|
||||
*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[.](#2.sentence-1)
|
||||
|
||||
The value of
|
||||
a [*has-attribute-expression*](cpp.cond#nt:has-attribute-expression "15.2 Conditional inclusion [cpp.cond]") for the fallthrough attribute
|
||||
should be 0 if the attribute does not cause suppression of such warnings[.](#2.sentence-2)
|
||||
|
||||
Implementations should issue a warning
|
||||
if a fallthrough statement is not dynamically reachable[.](#2.sentence-3)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L9802)
|
||||
|
||||
[*Example [1](#example-1)*: void f(int n) {void g(), h(), i(); switch (n) {case 1:case 2: g(); [[fallthrough]]; case 3: // warning on fallthrough discourageddo {[[fallthrough]]; // error: next statement is not part of the same substatement execution} while (false); case 6:do {[[fallthrough]]; // error: next statement is not part of the same substatement execution} while (n--); case 7:while (false) {[[fallthrough]]; // error: next statement is not part of the same substatement execution}case 5: h(); case 4: // implementation may warn on fallthrough i(); [[fallthrough]]; // error}} â *end example*]
|
||||
Reference in New Issue
Block a user