Fixed handling of function definitions with an empty parameter list. According
to the standard, an empty parameter list in a function declarator that is not a definition means that the function may have any number of parameters. In a function definition, it means that there are no parameters (as if the function were declared with a "void" parameter list). git-svn-id: svn://svn.cc65.org/cc65/trunk@3865 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
af9286852f
commit
c76a8657b3
1 changed files with 20 additions and 4 deletions
|
@ -6,8 +6,8 @@
|
|||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2004 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* (C) 2000-2008 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
|
@ -250,12 +250,28 @@ static void Parse (void)
|
|||
if (CurTok.Tok == TOK_SEMI) {
|
||||
/* Prototype only */
|
||||
NextToken ();
|
||||
} else if (Entry) {
|
||||
/* Function body definition */
|
||||
} else {
|
||||
|
||||
FuncDesc* D;
|
||||
|
||||
/* Function body. Check for duplicate function definitions */
|
||||
if (SymIsDef (Entry)) {
|
||||
Error ("Body for function `%s' has already been defined",
|
||||
Entry->Name);
|
||||
}
|
||||
|
||||
/* An empty parameter list in a function definition means
|
||||
* that the function doesn't take any parameters. The same
|
||||
* in a declarator means that the function can take any
|
||||
* number of parameters. This seems weird but is necessary
|
||||
* to support old K&R style programs.
|
||||
*/
|
||||
D = Entry->V.F.Func;
|
||||
if (D->Flags & FD_EMPTY) {
|
||||
D->Flags = (D->Flags & ~(FD_EMPTY | FD_VARIADIC)) | FD_VOID_PARAM;
|
||||
}
|
||||
|
||||
/* Parse the function body */
|
||||
NewFunc (Entry);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue