SLAU132Y September 2004 – June 2021
The __never_executed( ) intrinsic is specifically useful for testing the values of an MSP430 interrupt vector generator such as the vector generator for Timer A (TAIV). MSP430 vector generator values are mapped to an interrupt source and are characterized in that they fall within a specific range and can only take on even values. A common way to handle a particular interrupt source represented in a vector generator is to use a switch statement. However, a compiler is constrained by the C language in that it can make no assumptions about what values a switch expression may have. The compiler will have to generate code to handle every possible value, which leads to what would appear to be inefficient code.
The __never_executed( ) intrinsic can be used to assert to the compiler that a switch expression can only take on values represented by the case labels within a switch block. Having this assertion, the compiler can avoid generating test code for handling values not specified by the switch case labels. Having this assertion is specifically suited for handling values that characterize a vector generator.
Section 7.9.5.1.1 illustrates a switch block that handles the values of the Timer B (TBIV) vector generator.