if (!valid_declspecs(param, false))
return -1;
+ /* Check for "void" function parameters as a special case. */
for (spec = param->specifiers; spec; spec = spec->next) {
- if (spec->type == CDECL_TYPE_VOID
- && param->declarators->type == CDECL_DECL_NULL)
- has_void = true;
+ if (param->declarators->type != CDECL_DECL_NULL)
+ continue;
+ if (spec->type != CDECL_TYPE_VOID)
+ continue;
+
+ if (spec != param->specifiers || spec->next != NULL) {
+ fprintf(stderr, "void parameter must not have extra specifiers\n");
+ return -1;
+ } else if (d->u.function.parameters->next) {
+ fprintf(stderr, "a void parameter must stand alone\n");
+ return -1;
+ } else if (d->u.function.variadic) {
+ fprintf(stderr, "variadic functions cannot have a void parameter\n");
+ return -1;
+ }
}
}
- if (has_void && d->u.function.parameters->next) {
- fprintf(stderr, "a void parameter must stand alone\n");
- return -1;
- } else if (has_void && d->u.function.variadic) {
- fprintf(stderr, "variadic functions cannot have a void parameter\n");
- return -1;
- }
-
return 0;
}