From: cuz Date: Wed, 4 Apr 2001 20:20:48 +0000 (+0000) Subject: Fixed an internal error on too few params in function call X-Git-Tag: V2.12.0~2877 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=67aed641dbd059d2587b5d4f7f91a5714dbc906c;p=cc65 Fixed an internal error on too few params in function call git-svn-id: svn://svn.cc65.org/cc65/trunk@685 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 938f199d0..6d805f95c 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -644,15 +644,15 @@ static unsigned FunctionParamList (FuncDesc* Func) } else { unsigned ArgSize = sizeofarg (Flags); if (FrameSize > 0) { - /* We have the space already allocated, store in the frame */ - CHECK (FrameSize >= ArgSize); - FrameSize -= ArgSize; - FrameOffs -= ArgSize; - /* Store */ - g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.e_const); + /* We have the space already allocated, store in the frame */ + CHECK (FrameSize >= ArgSize); + FrameSize -= ArgSize; + FrameOffs -= ArgSize; + /* Store */ + g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.e_const); } else { /* Push the argument */ - g_push (Flags, lval.e_const); + g_push (Flags, lval.e_const); } /* Calculate total parameter size */ @@ -674,8 +674,15 @@ static unsigned FunctionParamList (FuncDesc* Func) Error ("Too few arguments in function call"); } - /* Return the size of all parameters pushed onto the stack */ - return ParamSize; + /* The function returns the size of all parameters pushed onto the stack. + * However, if there are parameters missing (which is an error and was + * flagged by the compiler) AND a stack frame was preallocated above, + * we would loose track of the stackpointer and generate an internal error + * later. So we correct the value by the parameters that should have been + * pushed to avoid an internal compiler error. Since an error was + * generated before, no code will be output anyway. + */ + return ParamSize + FrameSize; }