Implementation of DUTs
Topics:
Use attributes 'qualified_only' and 'strict' for enumeration
When defining an enumeration, use the attributes {attribute 'qualified_only'} and {attribute 'strict'}.
Static Analysis:
Verify using the following Static Analysis rules:
Negative sample:
TYPE E_SignalColor :
( 
    Red, 
    Yellow, 
    Green  
);
END_TYPEPositive sample:
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red,
    Yellow,
    Green
);
END_TYPEInitialize no value, only the first value or all values for enumeration
In an enumeration, you do not initialize any of the values, only the first one or all values with the allocation operator ':='.
Negative sample:
// NON COMPLIANT: init none, the first or all enumerators
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
( 
    Red    := 0,
    Yellow := 1,
    Green  
);
END_TYPEPositive sample 1:
// COMPLIANT: no enumerator is initialized
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red,
    Yellow,
    Green
);
END_TYPEPositive sample 2:
// COMPLIANT: first enumerator is initialized
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red  := 0,
    Yellow,
    Green
);
END_TYPEPositive sample 3:
// COMPLIANT: all enumerators are initialized
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red    := 0,
    Yellow := 1,
    Green  := 2
);
END_TYPE
See also: