Dialog ‘Project Settings’ - ‘Static Analysis Light’

Symbol: 0e31a3b0a7345218c0a8640e011b5c22_1dad4921a73cec32c0a8640e00c3db87

Function: This dialog defines the tests that the light version of CODESYS Static Analysis performs each time code is generated.

Call: Menu bar: Project ‣ Project Settings (Static Analysis Light category).

Note

You can use pragmas for deactivating certain parts of code.

Additional Compile Tests
SA033: Unused variables

Finds variables that are declared, but not used within the compiled program code.

For GVL variables: If there are multiple applications in one project, then only the objects under the currently active application are affected. If there is only one application, then the objects in the common POU pool are also affected.

SA0028: Overlapping memory areas Detects the locations where two or more variables reserve the same storage space. For example, this occurs for the following declarations: var1 AT %QB21: INT and var2 AT %QD5: DWORD. In this case, both variables use byte 21, which means that the memory range of the variables overlap.
SA0006: Write access from multiple tasks Detects variables that are written by more than one task.
SA0004 Multiple write access on output

Detects outputs that are written to more than one location. Exception:

Note: No error is reported when an output variable (VAR_IN_OUT) is written in different branches of IF and CASE statements.

Note: A pragma cannot deactivate this rule.

SA0027: Multiple use of identifiers

Detects multiple uses of a name/identifier for a variable or an object (POU) within the scope of a project. The following cases are detected:

The following cases are detected:

  • The name of an enumeration constant is the same as in another enumeration in the application or used in an included library.
  • The name of a variable is the same as an object in the application or an included library.
  • The name of a variable is the same as for an enumeration constant in and enumeration in the application or an included library.
  • The name of an object is the same as another object in the application or in an included library.
SA0167: Temporary function block instances The test detects function block instances that are declared as temporary variables. This concerns instances that are declared in a method or in a function or as VAR_TEMP, and therefore are reinitialized in each processing cycle and for each POU call.

Examples

SA0003: Empty statements

;
(* Comment *);
iVar;

SA0006: Concurrent access

FUNCTION_BLOCK ADD_FB
g_iTemp1 := g_iTemp1 + INT#1;
PROGRAM PLC_PRG  //controlled by MainTask
g_iTemp1 := g_iTemp1 + INT#2;
g_xTemp2 := g_iTemp1 > INT#10;
PROGRAM PLC_PRG_1  //controlled by SubTask
g_iTemp1 := g_iTemp1 - INT#3;
g_xTemp2 := g_iTemp1 < INT#-10;

SA0004 Multiple write access on output

VAR_GLOBAL
    g_xVar AT %QX0.0 : BOOL ;
    g_iTest AT %QW0 : INT ;
END_VAR
PROGRAM PLC_PRG
IF iCondition < INT#0 THEN
    g_xVar := TRUE;
    g_iTest := INT#12;
END_IF
CASE iCondition OF
    INT#1:
        g_xVar := FALSE;
    INT#2:
        g_iTest := INT#11;
    ELSE
        g_xVar := TRUE;
        g_iTest := INT#9;
END_CASE

SA0006: Write access from multiple tasks

FUNCTION_BLOCK ADD_FB
g_iTemp1 := g_iTemp1 + INT#1;

PROGRAM PLC_PRG  // Controlled by MainTask
g_iTemp1 := g_iTemp1 + INT#2;
g_xTemp2 := g_iTemp1 > INT#10;

PROGRAM PLC_PRG_1  //Controlled by SubTask
g_iTemp1 := g_iTemp1 - INT#3;
g_xTemp2 := g_iTemp1 < INT#-10;

SA0027: Multiple use of name

PROGRAM PLC_PRG
VAR
ton : INT;     // error SA0027
END_VAR

SA0029: Different notation in implementation and declaration

The PLC_PRG POU and a fnc function POU are in the device tree.

PROGRAM PLC_PRG
VAR
\ iVar:INT;
\ _123test_var_:INT;
END_VAR
\ ivar := iVar + 1; // notation different to that in the declaration part ->   SA0029
\ _123TEST_var_ := \ _123test_var_INT; // notation different to that in the declaration part ->   SA0029
 Fnc(); // notation different to that in the devices tree ->   SA0029
END_VAR

SA0167: Temporary function block instances

PROGRAM PLC_PRG
VAR
END_VAR
VAR_TEMP
    yafb: AFB;
END_VAR

FUNCTION Fun : INT
VAR_INPUT
END_VAR
VAR
    funafb: AFB;
END_VAR

METHOD METH : INT
VAR_INPUT
END_VAR
VAR
    methafb: AFB;
END_VAR

See also