Prohibit static initializers referring to a non-static array element.

This covers code like the following:

int main(void) {
        auto int a[20];
        static int *p = &a[5];
}

Previously, this would compile without error, and then either give a linker error or be linked to refer to the global symbol "a" (if there was one).
This commit is contained in:
Stephen Heumann 2023-03-21 09:10:37 -05:00
parent 3a64c5b977
commit 2412ae0661

View File

@ -2014,6 +2014,10 @@ var
iPtr^.pName := @'?';
end {if}
else begin
if ip^.storage in [stackFrame,parameter] then begin
Error(41);
errorFound := true;
end; {if}
Subscript := ip^.itype;
iPtr^.pName := ip^.name;
end; {else}