SA0053: Too big bitwise shift

Function

Determines whether the data type width was exceeded in bitwise shift of operands.

Reason

If a shift operation exceeds the data type width, a constant 0 is generated. If a rotation shift exceeds the data type width, it is difficult to read and the rotation value should therefore be shortened.

Importance

High

Samples:

PROGRAM MAIN
VAR
    nBYTE  : BYTE;
    nWORD  : WORD;
    nDWORD : DWORD;
    nLWORD : LWORD;
END_VAR
nBYTE  := SHR(nBYTE, BYTE#8);    // => SA0053 
nWORD  := SHL(nWORD, BYTE#45);   // => SA0053
nDWORD := ROR(nDWORD, BYTE#78);  // => SA0053
nLWORD := ROL(nLWORD, BYTE#111); // => SA0053

nBYTE  := SHR(nBYTE, BYTE#7);    // no error
nWORD  := SHL(nWORD, BYTE#15);   // no error