Give error for arrays that are still 0 size after initialization.

This prohibits empty initializers ({}) for arrays of unknown size, consistent with C23 requirements. Previous versions of C did not allow empty initializers at all, but ORCA/C historically did in some cases, so this patch still allows them for structs/unions/arrays of known size.
This commit is contained in:
Stephen Heumann 2022-11-30 17:57:21 -06:00
parent e7940db4c8
commit 94584b0f05

View File

@ -2595,9 +2595,15 @@ var
done := true;
until done or (token.kind = eofsy);
if maxCount = 0 then begin {set the array size}
maxCount := (maxDisp - startingDisp + ktp^.size - 1) div ktp^.size;
tp^.elements := maxCount;
RecomputeSizes(variable^.itype);
if maxDisp <> startingDisp then begin
maxCount := (maxDisp - startingDisp + ktp^.size-1) div ktp^.size;
tp^.elements := maxCount;
RecomputeSizes(variable^.itype);
end {if}
else begin
Error(49);
errorFound := true;
end; {else}
end; {if}
if braces then begin
disp := startingDisp + maxCount * ktp^.size;