Skip to content

Commit c0c6f1c

Browse files
committed
Allow parameter list to be a single "void"
A parameter list is either a single keyword "void" or a comma-separated list of parameters according to the standard. Previously, only the latter is supported, and the former leads to unexpected token errors.
1 parent 5ecfd87 commit c0c6f1c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/parser.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,17 @@ void read_parameter_list_decl(func_t *func, int anon)
596596
{
597597
int vn = 0;
598598
lex_expect(T_open_bracket);
599+
600+
char token[MAX_TYPE_LEN];
601+
if (lex_peek(T_identifier, token) && !strncmp(token, "void", 4)) {
602+
next_token = lex_token();
603+
if (lex_accept(T_close_bracket))
604+
return;
605+
strcpy(func->param_defs[vn].type_name, token);
606+
read_inner_var_decl(&func->param_defs[vn++], anon, 1);
607+
lex_accept(T_comma);
608+
}
609+
599610
while (lex_peek(T_identifier, NULL) == 1) {
600611
read_full_var_decl(&func->param_defs[vn++], anon, 1);
601612
lex_accept(T_comma);

0 commit comments

Comments
 (0)