SA0171: Enumerations should have the 'strict' attribute

Function

Detects declarations of enumerations which are not provided with the {attribute 'strict'} attribute.

Reason

The {attribute 'strict'} attribute causes compiler errors to be issued if the code violates strict programming rules for enumerations. By default, when a new enumeration is created, the declaration is automatically assigned the 'strict' attribute.

Importance

High

For more information see: PLC > Reference programming > Pragmas > Attribute pragmas > Attribute 'strict'

Sample:

{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_TrafficLight :
(
    eRed := 0,
    eYellow,
    eGreen
);
END_TYPE
{attribute 'qualified_only'}
TYPE E_MachineStates :           // => SA0171
(
    eStopped := 0,
    eRunning,
    eError
);
END_TYPE