Detects code locations where the address of an output variable (VAR_OUTPUT, VAR_IN_OUT) of a function block is is determined.
Justification: It is not allowed to use the address of a function block output in the following way:
By means of the ADR
operator
By means of REF =
Exception: No error is reported if the output is used within the same function block.
Importance: Medium
Example
Function block FB1
has a VAR_OUTPUT variable iOutVal : INT;
The following access in another POU generates Error SA0170:
//FB1_inst is of type FB1
addr1 := ADR(FB1_inst.iOutVal);
refINT REF= FB1_inst.iOutVal;
The following access directly within the FB1
function block also generates the error:
ptr := ADR(other^.iOutVal); //other is a POINTER TO FB1
The following access directly within the FB1
function block does not generate errors:
iOutVal := iInputVal; //iInputVal is a VAR_INPUT of FB1
ptr := ADR(THIS^.iOutVal); //ptr is a POINTER TO INT
ptr := ADR(iOutVal);