MISRA.SWITCH.WELL_FORMED.NESTED_LABEL.2012A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement.
MISRA C 2012 Rule 16.2: A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statementCategory: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 RationaleThe Standard permits a switch label, i.e. a case label or default label, to be placed before any statement contained in the body of a switch statement, potentially leading to unstructured code. In order to prevent this, a switch label shall only appear at the outermost level of the compound statement forming the body of a switch statement. Exampleswitch ( x ) { case 1: /* Compliant */ if ( flag ) { case 2: /* Non-compliant */ x = 1; } break; default: break; } See alsoRule 16.1 |