Next: , Previous: , Up: C Extensions   [Contents][Index]

6.36 Statement Attributes

GCC allows attributes to be set on null statements. See Attribute Syntax, for details of the exact syntax for using attributes. Other attributes are available for functions (see Function Attributes), variables (see Variable Attributes), labels (see Label Attributes), enumerators (see Enumerator Attributes), and for types (see Type Attributes).

This example uses the fallthrough statement attribute to indicate that the -Wimplicit-fallthrough warning should not be emitted:

switch (cond)
  case 1:
    bar (1);
  case 2:

The fallthrough attribute with a null statement serves as a fallthrough statement. It hints to the compiler that a statement that falls through to another case label, or user-defined label in a switch statement is intentional and thus the -Wimplicit-fallthrough warning must not trigger. The fallthrough attribute may appear at most once in each attribute list, and may not be mixed with other attributes. It can only be used in a switch statement (the compiler will issue an error otherwise), after a preceding statement and before a logically succeeding case label, or user-defined label.