Avoid generating invalid .sym files if header ends with a partial prototyped function decl.

This could happen because the nested calls to DoDeclaration for the parameters would set inhibitHeader to false.
This commit is contained in:
Stephen Heumann 2022-11-26 14:20:58 -06:00
parent 2bf3862e5d
commit 740468f75c
2 changed files with 7 additions and 5 deletions

View File

@ -3496,6 +3496,7 @@ var
isPascal: boolean; {has the pascal modifier been used?}
alignmentSpecified: boolean; {was an alignment explicitly specified?}
lDoingParameters: boolean; {local copy of doingParameters}
lInhibitHeader: boolean; {local copy of inhibitHeader}
lp,tlp,tlp2: identPtr; {for tracing parameter list}
lUseGlobalPool: boolean; {local copy of useGlobalPool}
nextPdisp: integer; {for calculating parameter disps}
@ -3699,6 +3700,7 @@ var
begin {DoDeclaration}
lInhibitHeader:= inhibitHeader;
inhibitHeader := true; {block imbedded includes in headers}
if token.kind = _Static_assertsy then begin
DoStaticAssert;
@ -3734,7 +3736,7 @@ isFunction := false; {assume it's not a function}
variable := nil;
Declarator(declSpecifiers, variable, variableSpace, doingPrototypes);
if variable = nil then begin
inhibitHeader := false;
inhibitHeader := lInhibitHeader;
if token.kind = semicolonch then begin
if not first then
Error(176);
@ -3830,7 +3832,7 @@ if isFunction then begin
end; {with}
doingParameters := doingPrototypes; {not doing parms any more}
if token.kind = semicolonch then begin
inhibitHeader := false;
inhibitHeader := lInhibitHeader;
NextToken; {skip the trailing semicolon}
end {if}
else if (token.kind = commach) and (not doingPrototypes) then begin
@ -4085,7 +4087,7 @@ else {if not isFunction then} begin
protoType := protoVariable^.iType;
end {if}
else begin
inhibitHeader := false;
inhibitHeader := lInhibitHeader;
if token.kind = semicolonch then {must end with a semicolon}
NextToken
else begin
@ -4098,7 +4100,7 @@ else {if not isFunction then} begin
doingParameters := lDoingParameters; {restore the status}
useGlobalPool := lUseGlobalPool;
4:
inhibitHeader := false;
inhibitHeader := lInhibitHeader;
end; {DoDeclaration}

View File

@ -1974,7 +1974,7 @@ int foo(int[42]);
219. If a function is first declared as "static" and then subsequently redeclared or defined as "extern" or with no storage-class specifier, it should be private to the source file, the same as if it was just declared "static".
220. A header that ended with a partial declaration would not be represented correctly in the .sym file. This could cause errors or misbehavior on subsequent compiles.
220. In certain cases where a header starts or ends in the middle of a declaration, it would not be represented correctly in the .sym file. This could cause errors or misbehavior on subsequent compiles.
-- Bugs from C 2.1.0 that have been fixed -----------------------------------