Skip to main content

SA0001: Unreachable code

Detects lines of code which are not executed, for example due to a RETURN or CONTINUE statement

Justification: Unreachable code should always be avoided. The test often indicates that test code still exists which should be removed.

Importance: High

PLCopen rule: CP2

Example 15. Example
PROGRAM PLC_PRG
VAR
    xReturn_Before_End: BOOL;
    xContinue_In_Loop_FUN: BOOL;
    iCounter: INT;
END_VAR
xContinue_In_Loop_FUN := FALSE;
FOR iCounter := INT#0 TO INT#5 BY INT#1 DO
    CONTINUE;
    xContinue_In_Loop_FUN := FALSE;
END_FOR

Output in the Messages view:

  • sa_icon_message.png SA0001: Unreachable code detected in 'PLC_PRG'