Fix field def allocation for function fields.

Assignment of nil to a field function is permitted, but trying to use one
as a builtin or as a normal function is treated as an error.
.void (float y) func;       OK
.void (float y) bi = #0;    error
.void (float y) ni = nil;   OK
.void (float y) co = { };   error
This commit is contained in:
Bill Currie 2011-02-22 12:07:31 +09:00
parent 7d1f2c4ef3
commit b50b392746

View file

@ -319,6 +319,7 @@ external_def
;
*type = parse_params (*type, $2);
$<spec>$.type = find_type ($<spec>$.type);
if ($<spec>$.type->type != ev_field)
$<spec>$.params = $2;
}
function_def_list
@ -721,6 +722,7 @@ qc_param_decl
;
*type = parse_params (*type, $2);
$3->type = find_type ($1.type);
if ($3->type->type != ev_field)
$3->params = $2;
$$ = new_param (0, $3->type, $3->name);
}
@ -838,9 +840,11 @@ overloaded_identifier
: identifier
{
$$ = $1;
$$->params = $<spec>0.params;
$$->type = $<spec>0.type;
if ($$->type->type != ev_field) {
$$ = function_symbol ($$, $<spec>0.is_overload, 1);
$$->params = $<spec>0.params;
}
}
;
@ -849,10 +853,23 @@ non_code_func
{
build_builtin_function ($<symbol>0, $3, 0);
}
| '=' fexpr
{
symbol_t *sym = $<symbol>0;
specifier_t spec = $<spec>-1;
initialize_def (sym, sym->type, $2, current_symtab->space,
spec.storage);
}
| /* emtpy */
{
symbol_t *sym = $<symbol>0;
specifier_t spec = $<spec>-1;
if (sym->type->type != ev_field) {
make_function (sym, 0, sym->table->space, current_storage);
} else {
initialize_def (sym, sym->type, 0, current_symtab->space,
spec.storage);
}
}
;