diff --git a/CGI.pas b/CGI.pas index a243c67..262e671 100644 --- a/CGI.pas +++ b/CGI.pas @@ -329,6 +329,7 @@ var symLength: integer; {length of debug symbol table} toolParms: boolean; {generate tool format paramaters?} 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 84ca69d..1565443 100644 --- a/Expression.pas +++ b/Expression.pas @@ -2781,6 +2781,8 @@ var Gen1tName(pc_cup, ord(fType^.varargs and strictVararg), UsualUnaryConversions, fname); end; {else} + if fType^.varargs 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 0068af3..7e39220 100644 --- a/Gen.pas +++ b/Gen.pas @@ -5679,7 +5679,7 @@ while bk <> nil do begin end; {while} bk := bk^.next; end; {while} -if saveStack or checkStack or strictVararg 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 278e46a..cce68d6 100644 --- a/Parser.pas +++ b/Parser.pas @@ -3474,6 +3474,7 @@ if isFunction then begin else Gen2Name (dc_str, segType, 0, variable^.name); doingMain := variable^.name^ = 'main'; + hasVarargsCall := false; firstCompoundStatement := true; Gen0 (dc_pin); if not isAsm then