mirror of https://github.com/rui314/chibicc
Accept `void` as a parameter list
`foo(void)` indicate that function foo does not take a parameter.
This commit is contained in:
parent
1e7c50c454
commit
7938157072
7
parse.c
7
parse.c
|
@ -540,6 +540,11 @@ VarList *read_func_params() {
|
|||
if (consume(")"))
|
||||
return NULL;
|
||||
|
||||
Token *tok = token;
|
||||
if (consume("void") && consume(")"))
|
||||
return NULL;
|
||||
token = tok;
|
||||
|
||||
VarList *head = read_func_param();
|
||||
VarList *cur = head;
|
||||
|
||||
|
@ -553,7 +558,7 @@ VarList *read_func_params() {
|
|||
}
|
||||
|
||||
// function = type-specifier declarator "(" params? ")" ("{" stmt* "}" | ";")
|
||||
// params = param ("," param)*
|
||||
// params = param ("," param)* | "void"
|
||||
// param = type-specifier declarator type-suffix
|
||||
Function *function() {
|
||||
locals = NULL;
|
||||
|
|
Loading…
Reference in New Issue