Indicates that the fall through from the previous case label is intentional and should not be diagnosed by a compiler that warns on fallthrough.
Contents |
[[fallthrough]][[__fallthrough__]] | |||||||||
May only be used in anattribute declaration to create afallthrough declaration ([[fallthrough]];).
A fallthrough declaration may only be used in aswitch statement, where the next block item (statement, declaration, or label) to be encounted is a statement with acase ordefault label for that switch statement.
Indicates that the fall through from the previous case label is intentional and should not be diagnosed by a compiler that warns on fallthrough.
#include <stdbool.h> void g(void){}void h(void){}void i(void){} void f(int n){switch(n){case1:case2: g();[[fallthrough]];case3:// no warning on fallthrough h();case4:// compiler may warn on fallthroughif(n<3){ i();[[fallthrough]];// OK}else{return;}case5:while(false){[[fallthrough]];// ill-formed: no subsequent case or default label}case6:[[fallthrough]];// ill-formed: no subsequent case or default label}} int main(void){}
C++ documentation forfallthrough |