cpp/language/attributes/fallthrough
From cppreference.com
Template:cpp/attribute/title Template:cpp/attribute/navbar
Indicates that the fall through from the previous case label is intentional and should not be diagnosed by a compiler that warns on fallthrough.
Syntax
[[fallthrough]];
|
|||||||||
Explanation
Appears in a switch statement on a line of its own (technically as an attribute of a null statement), immediately before a case label. Indicates that the fall through from the previous case label is intentional and should not be diagnosed by a compiler that warns on fallthrough.
Example
Run this code
void f(int n) { void g(), h(), i(); switch (n) { case 1: case 2: g(); [[fallthrough]]; case 3: // no warning on fallthrough h(); case 4: // compiler may warn on fallthrough i(); [[fallthrough]]; // illformed, not before a case label } }