Skip to content

Commit 059a771

Browse files
committed
Fix non-only or named "void" in parameter lists
'void' must be the only parameter and unnamed to indicate no parameters. Previously, the check for functions with first parameter of void pointer, etc. didn't consider the illegal forms, so those could pass compilation.
1 parent 05cce14 commit 059a771

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/parser.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,11 @@ void read_parameter_list_decl(func_t *func, int anon)
735735
if (lex_accept(T_close_bracket))
736736
return;
737737
func->param_defs[vn].type = TY_void;
738-
read_inner_var_decl(&func->param_defs[vn++], anon, 1);
738+
read_inner_var_decl(&func->param_defs[vn], anon, 1);
739+
if (!func->param_defs[vn].is_ptr && !func->param_defs[vn].is_func &&
740+
!func->param_defs[vn].array_size)
741+
error("'void' must be the only parameter and unnamed");
742+
vn++;
739743
lex_accept(T_comma);
740744
}
741745

0 commit comments

Comments
 (0)