mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-09-27 03:54:30 +00:00
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:
parent
d24dacf01a
commit
9862500dee
15
Parser.pas
15
Parser.pas
@ -3560,19 +3560,28 @@ if isFunction then begin
|
|||||||
begin
|
begin
|
||||||
tlp := lp;
|
tlp := lp;
|
||||||
while tlp <> nil do begin
|
while tlp <> nil do begin
|
||||||
if tlp^.itype = nil then
|
if tlp^.itype = nil then begin
|
||||||
tlp^.itype := wordPtr;
|
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;
|
tlp := tlp^.pnext;
|
||||||
end; {while}
|
end; {while}
|
||||||
end; {if}
|
end; {if}
|
||||||
tlp := lp; {make sure all parameters have an}
|
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
|
if tlp^.name^ = '?' then begin
|
||||||
Error(113);
|
Error(113);
|
||||||
tlp := nil;
|
tlp := nil;
|
||||||
end {if}
|
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;
|
tlp := tlp^.pnext;
|
||||||
|
end; {else}
|
||||||
|
end; {while}
|
||||||
doingParameters := false;
|
doingParameters := false;
|
||||||
fName := variable^.name; {skip if this is not needed for a }
|
fName := variable^.name; {skip if this is not needed for a }
|
||||||
if doingPartial then { partial compile }
|
if doingPartial then { partial compile }
|
||||||
|
@ -668,6 +668,8 @@ if list or (numErr <> 0) then begin
|
|||||||
144: msg := @'generic selection expressions are not supported by ORCA/C';
|
144: msg := @'generic selection expressions are not supported by ORCA/C';
|
||||||
145: msg := @'invalid universal character name';
|
145: msg := @'invalid universal character name';
|
||||||
146: msg := @'Unicode character cannot be represented in execution character set';
|
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);
|
otherwise: Error(57);
|
||||||
end; {case}
|
end; {case}
|
||||||
writeln(msg^);
|
writeln(msg^);
|
||||||
|
Loading…
Reference in New Issue
Block a user