SLAU132V October 2004 – February 2020
switch( val)
{
case 0:
case 5: action(a); break;
case 14: action(b); break;
default: __never_executed();
}
Normally, for the switch expression values 0 and 5, the compiler generates code to test for both 0 and 5 since the compiler must handle the possible values 1−4. The __never_executed( ) intrinsic in Example 9 asserts that val cannot take on the values 1−4 and therefore the compiler only needs to generate a single test (val < 6) to handle both case labels.
Additionally, using the __never_executed( ) intrinsic results in the assertion that if val is not 0 or 5 then it has to be 14 and the compiler has no need to generate code to test for val == 14.
The __never_executed( ) intrinsic is only defined when specified as the single statement following a default case label. The compiler ignores the use of the intrinsic in any other context.