RECORD Fields with Identical Identifier
Posted: Sat Apr 27, 2024 6:32 am
Via a typo I have come across this (Astrobe for Cortex-M0v 9.1):
Looking at the assembly code for 'p':
It appears the second definition of 'x' "shadows" the first. I don't believe this RECORD definition should be allowed.
Code: Select all
MODULE M;
TYPE
R = RECORD
x: INTEGER;
x: INTEGER;
y: INTEGER
END;
PROCEDURE p;
VAR r: R;
BEGIN
r.x := 13;
r.y := 17
END p;
END M.
Code: Select all
PROCEDURE p;
VAR r: R;
BEGIN
. 24 018H 0B500H push { lr }
. 26 01AH 0B083H sub sp,#12
r.x := 13;
. 28 01CH 0200DH movs r0,#13
. 30 01EH 09001H str r0,[sp,#4]
r.y := 17
END p;
. 32 020H 02011H movs r0,#17
. 34 022H 09002H str r0,[sp,#8]
. 36 024H 0B003H add sp,#12
. 38 026H 0BD00H pop { pc }