diff --git a/CGI.pas b/CGI.pas index ffd53fd..759d137 100644 --- a/CGI.pas +++ b/CGI.pas @@ -364,6 +364,7 @@ var symLength: integer; {length of debug symbol table} toolParms: boolean; {generate tool format parameters?} volatile: boolean; {has a volatile qualifier been used?} + hasVarargsCall: boolean; {does current function call any varargs fns?} {desk accessory variables} {------------------------} diff --git a/Expression.pas b/Expression.pas index 3bec4e3..9618172 100644 --- a/Expression.pas +++ b/Expression.pas @@ -3508,6 +3508,8 @@ var Gen1tName(pc_cup, ord(hasVarargs and strictVararg), UsualUnaryConversions, fname); end; {else} + if hasVarargs then + hasVarargsCall := true; end {if} else GenTool(pc_tl1, ftype^.toolNum, long(ftype^.ftype^.size).lsw, diff --git a/Gen.pas b/Gen.pas index 9a554db..2a9c094 100644 --- a/Gen.pas +++ b/Gen.pas @@ -7679,7 +7679,7 @@ while bk <> nil do begin end; {while} bk := bk^.next; end; {while} -if saveStack or checkStack then begin +if saveStack or checkStack or (strictVararg and hasVarargsCall) then begin stackLoc := minSize; minSize := minSize + 2; localSize := localSize + 2; diff --git a/Parser.pas b/Parser.pas index 2c14fa0..25bf3d1 100644 --- a/Parser.pas +++ b/Parser.pas @@ -4019,6 +4019,7 @@ if isFunction then begin end; {if} Gen2Name(dc_str, segType, 0, fName); doingMain := variable^.name^ = 'main'; + hasVarargsCall := false; firstCompoundStatement := true; Gen0 (dc_pin); if not isAsm then