Skip to content

Commit 05cce14

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 ad445a7 commit 05cce14

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
@@ -728,6 +728,17 @@ void read_parameter_list_decl(func_t *func, int anon)
728728
{
729729
int vn = 0;
730730
lex_expect(T_open_bracket);
731+
732+
char token[MAX_TYPE_LEN];
733+
if (lex_peek(T_identifier, token) && !strncmp(token, "void", 4)) {
734+
next_token = lex_token();
735+
if (lex_accept(T_close_bracket))
736+
return;
737+
func->param_defs[vn].type = TY_void;
738+
read_inner_var_decl(&func->param_defs[vn++], anon, 1);
739+
lex_accept(T_comma);
740+
}
741+
731742
while (lex_peek(T_identifier, NULL) == 1) {
732743
read_full_var_decl(&func->param_defs[vn++], anon, 1);
733744
lex_accept(T_comma);

0 commit comments

Comments
 (0)