1
0
mirror of https://github.com/cc65/cc65.git synced 2025-03-13 15:32:09 +00:00

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
This commit is contained in:
cuz 2001-04-04 20:20:48 +00:00
parent b8e26d3612
commit 67aed641db

View File

@ -644,15 +644,15 @@ static unsigned FunctionParamList (FuncDesc* Func)
} else { } else {
unsigned ArgSize = sizeofarg (Flags); unsigned ArgSize = sizeofarg (Flags);
if (FrameSize > 0) { if (FrameSize > 0) {
/* We have the space already allocated, store in the frame */ /* We have the space already allocated, store in the frame */
CHECK (FrameSize >= ArgSize); CHECK (FrameSize >= ArgSize);
FrameSize -= ArgSize; FrameSize -= ArgSize;
FrameOffs -= ArgSize; FrameOffs -= ArgSize;
/* Store */ /* Store */
g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.e_const); g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.e_const);
} else { } else {
/* Push the argument */ /* Push the argument */
g_push (Flags, lval.e_const); g_push (Flags, lval.e_const);
} }
/* Calculate total parameter size */ /* Calculate total parameter size */
@ -674,8 +674,15 @@ static unsigned FunctionParamList (FuncDesc* Func)
Error ("Too few arguments in function call"); Error ("Too few arguments in function call");
} }
/* Return the size of all parameters pushed onto the stack */ /* The function returns the size of all parameters pushed onto the stack.
return ParamSize; * 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;
} }