mirror of
https://github.com/cc65/cc65.git
synced 2025-01-03 01:31:55 +00:00
Fixed a bug that caused problems locating the last parameter of a function
git-svn-id: svn://svn.cc65.org/cc65/trunk@2259 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
9a34fdb41e
commit
73dfa23c98
@ -287,8 +287,7 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg)
|
||||
FuncDesc* D = E->V.F.Func;
|
||||
if ((D->Flags & FD_FASTCALL) != 0 && D->ParamCount > 0) {
|
||||
/* Will use registers depending on the last param */
|
||||
SymEntry* LastParam = D->SymTab->SymTail;
|
||||
unsigned LastParamSize = CheckedSizeOf (LastParam->Type);
|
||||
unsigned LastParamSize = CheckedSizeOf (D->LastParam->Type);
|
||||
if (LastParamSize == 1) {
|
||||
*Use = REG_A;
|
||||
} else if (LastParamSize == 2) {
|
||||
|
@ -806,11 +806,18 @@ static FuncDesc* ParseFuncDecl (const DeclSpec* Spec)
|
||||
ParseOldStyleParamList (F);
|
||||
}
|
||||
|
||||
/* Remember the last function parameter. We need it later for several
|
||||
* purposes, for example when passing stuff to fastcall functions. Since
|
||||
* more symbols are added to the table, it is easier if we remember it
|
||||
* now, since it is currently the last entry in the symbol table.
|
||||
*/
|
||||
F->LastParam = GetSymTab()->SymTail;
|
||||
|
||||
/* Assign offsets. If the function has a variable parameter list,
|
||||
* there's one additional byte (the arg size).
|
||||
*/
|
||||
Offs = (F->Flags & FD_VARIADIC)? 1 : 0;
|
||||
Sym = GetSymTab()->SymTail;
|
||||
Sym = F->LastParam;
|
||||
while (Sym) {
|
||||
unsigned Size = CheckedSizeOf (Sym->Type);
|
||||
if (SymIsRegVar (Sym)) {
|
||||
|
@ -583,8 +583,7 @@ static unsigned FunctionParamList (FuncDesc* Func)
|
||||
FrameSize = Func->ParamSize;
|
||||
if (FrameParams > 0 && (Func->Flags & FD_FASTCALL) != 0) {
|
||||
/* Last parameter is not pushed */
|
||||
const SymEntry* LastParam = Func->SymTab->SymTail;
|
||||
FrameSize -= CheckedSizeOf (LastParam->Type);
|
||||
FrameSize -= CheckedSizeOf (Func->LastParam->Type);
|
||||
--FrameParams;
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ FuncDesc* NewFuncDesc (void)
|
||||
F->TagTab = 0;
|
||||
F->ParamCount = 0;
|
||||
F->ParamSize = 0;
|
||||
F->LastParam = 0;
|
||||
|
||||
/* Return the new struct */
|
||||
return F;
|
||||
|
@ -67,6 +67,7 @@ struct FuncDesc {
|
||||
struct SymTable* TagTab; /* Symbol table for structs/enums */
|
||||
unsigned ParamCount; /* Number of parameters */
|
||||
unsigned ParamSize; /* Size of the parameters */
|
||||
struct SymEntry* LastParam; /* Pointer to last parameter */
|
||||
};
|
||||
|
||||
|
||||
|
@ -334,7 +334,6 @@ void NewFunc (SymEntry* Func)
|
||||
/* Parse argument declarations and function body. */
|
||||
{
|
||||
int HadReturn;
|
||||
SymEntry* LastParam;
|
||||
SymEntry* Param;
|
||||
|
||||
/* Get the function descriptor from the function entry */
|
||||
@ -346,9 +345,6 @@ void NewFunc (SymEntry* Func)
|
||||
/* Reenter the lexical level */
|
||||
ReenterFunctionLevel (D);
|
||||
|
||||
/* Before adding more symbols, remember the last parameter for later */
|
||||
LastParam = D->SymTab->SymTail;
|
||||
|
||||
/* Declare two special functions symbols: __fixargs__ and __argsize__.
|
||||
* The latter is different depending on the type of the function (variadic
|
||||
* or not).
|
||||
@ -394,11 +390,11 @@ void NewFunc (SymEntry* Func)
|
||||
CHECK ((D->Flags & FD_VARIADIC) == 0);
|
||||
|
||||
/* Generate the push */
|
||||
if (IsTypeFunc (LastParam->Type)) {
|
||||
if (IsTypeFunc (D->LastParam->Type)) {
|
||||
/* Pointer to function */
|
||||
Flags = CF_PTR;
|
||||
} else {
|
||||
Flags = TypeOf (LastParam->Type) | CF_FORCECHAR;
|
||||
Flags = TypeOf (D->LastParam->Type) | CF_FORCECHAR;
|
||||
}
|
||||
g_push (Flags, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user