Give an error if the element type of an array type is an incomplete or function type.

This commit is contained in:
Stephen Heumann 2018-03-06 22:46:23 -06:00
parent 96f04b168e
commit c55acd1150
2 changed files with 7 additions and 0 deletions

View File

@ -3024,12 +3024,18 @@ var
tp := v^.itype; {initialize the type pointer}
while tp <> nil do begin {check all types}
if tp^.kind = arrayType then {if it's an array with an unspecified }
begin
if tp^.elements = 0 then { size and an unspecified size is not }
if not firstVariable then { allowed here, flag an error. }
begin
Error(49);
goto 1;
end; {if}
if tp^.aType^.size = 0 then begin
Error(123);
goto 1;
end; {if}
end; {if}
firstVariable := false; {unspecified sizes are only allowed in }
{ the first subscript }
case tp^.kind of {next type...}

View File

@ -610,6 +610,7 @@ if list or (numErr <> 0) then begin
120: msg := @'non-static inline functions are not supported';
121: msg := @'invalid digit for binary constant';
122: msg := @'arithmetic is not allowed on a pointer to an incomplete or function type';
123: msg := @'array element type may not be an incomplete or function type';
otherwise: Error(57);
end; {case}
writeln(msg^);