1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-05 15:30:44 +00:00

Optimized parameter list checking.

Fixed function type comparison between ANSI and K&R styles.
This commit is contained in:
acqn 2020-08-15 06:27:11 +08:00 committed by Oliver Schmidt
parent 0a96ffc878
commit 33a75e0a73
3 changed files with 11 additions and 3 deletions

View File

@ -1753,6 +1753,7 @@ static FuncDesc* ParseFuncDecl (void)
/* It is allowed to use incomplete types in function prototypes, so we
** won't always get to know the parameter sizes here and may do that later.
*/
F->Flags |= FD_INCOMPLETE_PARAM;
/* Leave the lexical level remembering the symbol tables */
RememberFunctionLevel (F);

View File

@ -49,13 +49,14 @@
#define FD_EMPTY 0x0001U /* Function with empty param list */
#define FD_VOID_PARAM 0x0002U /* Function with a void param list */
#define FD_VARIADIC 0x0004U /* Function with variable param list */
#define FD_INCOMPLETE_PARAM 0x0008U /* Function with param of unknown size */
#define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */
#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */
#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */
#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */
/* Bits that must be ignored when comparing funcs */
#define FD_IGNORE (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER)
#define FD_IGNORE (FD_INCOMPLETE_PARAM | FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER)

View File

@ -117,6 +117,11 @@ int F_CheckParamList (FuncDesc* D, int RequireAll)
unsigned ParamSize = 0;
unsigned IncompleteCount = 0;
/* Don't bother to check unnecessarily */
if ((D->Flags & FD_INCOMPLETE_PARAM) == 0) {
return 1;
}
/* Assign offsets. If the function has a variable parameter list,
** there's one additional byte (the arg size).
*/
@ -147,11 +152,12 @@ int F_CheckParamList (FuncDesc* D, int RequireAll)
++I;
}
/* If all parameters have complete types, set the total size description
** and return true.
/* If all parameters have complete types, set the total size description,
** clear the FD_INCOMPLETE_PARAM flag and return true.
*/
if (IncompleteCount == 0) {
D->ParamSize = ParamSize;
D->Flags &= ~FD_INCOMPLETE_PARAM;
return 1;
}