Scan the param list for problems with void.

This commit is contained in:
Bill Currie 2011-02-01 21:18:08 +09:00
parent c53001800a
commit 80ce179bc2
2 changed files with 27 additions and 0 deletions

View file

@ -88,6 +88,7 @@ param_t *_reverse_params (param_t *params, param_t *next);
param_t *reverse_params (param_t *params);
param_t *copy_params (param_t *params);
struct type_s *parse_params (struct type_s *type, param_t *params);
param_t *check_params (param_t *params);
enum storage_class_e;
void make_function (struct symbol_s *sym, const char *nice_name,

View file

@ -181,6 +181,32 @@ parse_params (type_t *type, param_t *parms)
return find_type (&new);
}
param_t *
check_params (param_t *params)
{
int num = 1;
param_t *p = params;
if (!params)
return 0;
while (p) {
if (p->type == &type_void) {
if (p->name) {
error (0, "parameter %d ('%s') has incomplete type", num,
p->name);
p->type = type_default;
} else if (num > 1 || p->next) {
error (0, "'void' must be the only parameter");
p->name = "void";
} else {
// this is a void function
return 0;
}
}
p = p->next;
}
return params;
}
static overloaded_function_t *
get_function (const char *name, type_t *type, int overload, int create)
{