SA0075: Missing ELSE
Function | Determines CASE statements without ELSE branch. |
Reason | Defensive programming requires the presence of an ELSE in every CASE statement. If no action is required in the ELSE case, you should indicate this with a comment. The reader of the code is then aware that the case was not simply overlooked. |
Exception | A missing ELSE branch is not reported as missing if an enumeration declared with the 'strict' attribute is used in the CASE statement, and if all enumeration constants are listed in that CASE statement. |
Importance | Low |
PLCopen rule | L17 |
Sample:
{attribute 'qualified_only'}
{attribute 'strict'}
{attribute 'to_string'}
TYPE E_Sample :
(
eNull,
eOne,
eTwo
);
END_TYPEPROGRAM MAIN
VAR
eSample : E_Sample;
nVar : INT;
END_VARCASE eSample OF
E_Sample.eNull: nVar := 0;
E_Sample.eOne: nVar := 1;
E_Sample.eTwo: nVar := 2;
END_CASE
CASE eSample OF // => SA0075
E_Sample.eNull: nVar := 0;
E_Sample.eTwo: nVar := 2;
END_CASE