Optimized parameter list checking.
Fixed function type comparison between ANSI and K&R styles.
This commit is contained in:
@@ -1753,6 +1753,7 @@ static FuncDesc* ParseFuncDecl (void)
|
|||||||
/* It is allowed to use incomplete types in function prototypes, so we
|
/* 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.
|
** 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 */
|
/* Leave the lexical level remembering the symbol tables */
|
||||||
RememberFunctionLevel (F);
|
RememberFunctionLevel (F);
|
||||||
|
|||||||
@@ -49,13 +49,14 @@
|
|||||||
#define FD_EMPTY 0x0001U /* Function with empty param list */
|
#define FD_EMPTY 0x0001U /* Function with empty param list */
|
||||||
#define FD_VOID_PARAM 0x0002U /* Function with a void param list */
|
#define FD_VOID_PARAM 0x0002U /* Function with a void param list */
|
||||||
#define FD_VARIADIC 0x0004U /* Function with variable 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 0x0010U /* Old style (K&R) function */
|
||||||
#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */
|
#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */
|
||||||
#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */
|
#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */
|
||||||
#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */
|
#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */
|
||||||
|
|
||||||
/* Bits that must be ignored when comparing funcs */
|
/* 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ int F_CheckParamList (FuncDesc* D, int RequireAll)
|
|||||||
unsigned ParamSize = 0;
|
unsigned ParamSize = 0;
|
||||||
unsigned IncompleteCount = 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,
|
/* Assign offsets. If the function has a variable parameter list,
|
||||||
** there's one additional byte (the arg size).
|
** there's one additional byte (the arg size).
|
||||||
*/
|
*/
|
||||||
@@ -147,11 +152,12 @@ int F_CheckParamList (FuncDesc* D, int RequireAll)
|
|||||||
++I;
|
++I;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If all parameters have complete types, set the total size description
|
/* If all parameters have complete types, set the total size description,
|
||||||
** and return true.
|
** clear the FD_INCOMPLETE_PARAM flag and return true.
|
||||||
*/
|
*/
|
||||||
if (IncompleteCount == 0) {
|
if (IncompleteCount == 0) {
|
||||||
D->ParamSize = ParamSize;
|
D->ParamSize = ParamSize;
|
||||||
|
D->Flags &= ~FD_INCOMPLETE_PARAM;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user