SA0076: Missing enumeration constant

Function

Determines whether each enumeration constant is used as a condition in CASE statements and queried in a CASE branch.

Reason

Defensive programming requires the processing of all possible values of an enumeration. If no action is required for a particular enumeration value, you should indicate this explicitly with a comment. This makes it clear that the value was not simply overlooked.

Importance

Low

Sample:

In the following sample the enumeration value eYellow is not treated as a CASE branch.

Enumeration E_Color:

TYPE E_Color :
(
    eRed,
    eGreen,
    eBlue,
    eYellow
);
END_TYPE

MAIN program:

PROGRAM MAIN
VAR
    eColor : E_Color;
    bVar   : BOOL;
END_VAR
eColor := E_Color.eYellow;
 
CASE eColor OF                   // => SA0076
    E_Color.eRed:
         bVar := FALSE;
 
    E_Color.eGreen,
    E_Color.eBlue:
         bVar := TRUE;
 
ELSE
    bVar := NOT bVar;
END_CASE