SA0076: Missing enumeration constant
Determines whether or not each enumeration constant is used as a condition in CASE
statements and queried in a CASE
branch.
Justification: Defensive programming requires the processing of all possible values of an enumeration. If an action is not required for a particular enumeration value, then you should add a comment to indicate this explicitly. It is then clear to the reader of the code that the value was not simply forgotten.
Importance: Low
Example 83. Example
TYPE My_Enum : ( red := 1, blue := 2, green := 3, black := 4 ); END_TYPE
PROGRAM PLC_PRG VAR iVar : My_Enum; xTemp : BOOL; END_VAR
iVar := My_Enum.black; CASE iVar OF My_Enum.red: xTemp := FALSE; My_Enum.blue, My_Enum.green: xTemp := TRUE; ELSE xTemp := NOT xTemp; END_CASE
Output in the Messages view:
SA0076: Missing enumeration constant 'black' in CASE statement