B2032: an enumeration representation clause whose codes are not one static, increasing code per literal
Catalog status: active. Default severity: error. Stable name: enumeration-codes. Family: Types and constraints.
An enumeration representation clause (for T use (A => 1, B => 2, C => 4);) gives each literal of T the code it is stored as. Verada keeps the values as positions and uses the codes wherever a value is stored (a field of a laid-out record, an object at an address), for 'Enum_Rep and 'Enum_Val, and for Unchecked_Conversion. So the clause must give every literal exactly one static code, named or in order, and the codes must increase with the literals' order (RM 13.4).
Example (Vada)
type Speed is (Off, Slow, Fast);
for Speed use (Off => 0, Slow => 8, Fast => 4);Fast comes after Slow, so its code must be greater.
What to do (Vada)
Give the codes in the literals' order, or reorder the literals:
type Speed is (Off, Slow, Fast);
for Speed use (Off => 0, Slow => 4, Fast => 8);Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See types and constraints, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.