C++11の属性(attribute)は空文に対しても指定可能。
Clangではswitch構文caseラベルにてfall-through動作を明示できる。このとき空文(;
のみ)に独自拡張のclang::fallthrough
属性を指定する。
- 2020-05-05追記:
fallthrough
属性はC++17から標準サポートされている。またC2x(C23)標準でもfallthorugh属性サポートが予定されている(→id:yohhoy:20200505)
The
clang::fallthrough
attribute// compile with -Wimplicit-fallthrough switch (n) { case 22: case 33: // no warning: no statements between case labels f(); case 44: // warning: unannotated fall-through g(); [[clang::fallthrough]]; case 55: // no warning // (snip) }Clang Language Extensions - Non-standard C++11 Attributes
C++11(N3337) A.5 Statementsより構文定義を一部引用。
statement:
attribute-specifier-seqopt expression-statement
(snip)expression-statement:
expressionopt;
(snip)
関連URL