Give an error if a parameter in a function definition has an incomplete type.

In combination with earlier patches, this fixes #53.

Also, if the lint flag requiring explicit function types is set, then also require that K&R-style parameters be explicitly declared with types, rather than not being declared and defaulting to int. (This is a requirement in C99 and later.)
This commit is contained in:
Stephen Heumann 2020-01-20 12:43:01 -06:00
parent d24dacf01a
commit 9862500dee
2 changed files with 14 additions and 3 deletions

View File

@ -3560,19 +3560,28 @@ if isFunction then begin
begin
tlp := lp;
while tlp <> nil do begin
if tlp^.itype = nil then
if tlp^.itype = nil then begin
tlp^.itype := wordPtr;
if (lint & lintNoFnType) <> 0 then
if (lint & lintNotPrototyped) = 0 then
Error(147); {C99+ require K&R params to be declared}
end; {if}
tlp := tlp^.pnext;
end; {while}
end; {if}
tlp := lp; {make sure all parameters have an}
while tlp <> nil do { identifier }
while tlp <> nil do begin { identifier and a complete type }
if tlp^.name^ = '?' then begin
Error(113);
tlp := nil;
end {if}
else
else begin
if tlp^.itype^.size = 0 then
if not (tlp^.itype^.kind in [arrayType,functionType]) then
Error(148);
tlp := tlp^.pnext;
end; {else}
end; {while}
doingParameters := false;
fName := variable^.name; {skip if this is not needed for a }
if doingPartial then { partial compile }

View File

@ -668,6 +668,8 @@ if list or (numErr <> 0) then begin
144: msg := @'generic selection expressions are not supported by ORCA/C';
145: msg := @'invalid universal character name';
146: msg := @'Unicode character cannot be represented in execution character set';
147: msg := @'lint: not all parameters were declared with a type';
148: msg := @'all parameters must have a complete type';
otherwise: Error(57);
end; {case}
writeln(msg^);