Allow functions without parameters

- Fixed: Trying to define a function without any parameters would silently
  discard the function, because the declarator tested FuncParams instead
  of FuncName to decide if it was a function.
This commit is contained in:
Randy Heit 2013-07-23 20:43:15 -05:00
parent 67caf3303b
commit a136ca65ea
1 changed files with 2 additions and 2 deletions

View File

@ -522,11 +522,11 @@ array_size(X) ::= array_size(A) array_size_expr(B).
/* Multiple type names are only valid for functions. */ /* Multiple type names are only valid for functions. */
declarator(X) ::= decl_flags(A) type_list_or_void(B) variables_or_function(C). declarator(X) ::= decl_flags(A) type_list_or_void(B) variables_or_function(C).
{ {
if (C.FuncParams == NULL && C.VarNames == NULL) if (C.FuncName == NAME_None && C.VarNames == NULL)
{ // An error. A message was already printed. { // An error. A message was already printed.
X = NULL; X = NULL;
} }
else if (C.FuncParams != NULL) else if (C.FuncName != NAME_None)
{ // A function { // A function
NEW_AST_NODE(FuncDeclarator, decl); NEW_AST_NODE(FuncDeclarator, decl);
decl->Type = B; decl->Type = B;