But what about a return statement like in the example below.
Code: Select all
switch ( x )
return; // Compliant or non-compliant?
case 1: // Compliant - empty drop through
case 2: // allows a group
break; // Compliant
throw; // Compliant
a = b;
// Non-compliant - non empty drop through
; // Non-compliant – default must also have "break"
The return statement for case 0: avoids an unintentional fall-through to next switch-clause.
For that reason an unconditional return at end of a switch-clause should make the switch-clause also compliant to this rule.
Is return as last statement of a switch-clause also compliant to this rule?