From b50b392746c8c9471aee502dac8bc7543d323844 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 22 Feb 2011 12:07:31 +0900 Subject: [PATCH] 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 --- tools/qfcc/source/qc-parse.y | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index ac7967422..daa1a09e5 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -319,7 +319,8 @@ external_def ; *type = parse_params (*type, $2); $$.type = find_type ($$.type); - $$.params = $2; + if ($$.type->type != ev_field) + $$.params = $2; } function_def_list | optional_specifiers function_decl function_body @@ -721,7 +722,8 @@ qc_param_decl ; *type = parse_params (*type, $2); $3->type = find_type ($1.type); - $3->params = $2; + if ($3->type->type != ev_field) + $3->params = $2; $$ = new_param (0, $3->type, $3->name); } | ELLIPSIS { $$ = new_param (0, 0, 0); } @@ -838,9 +840,11 @@ overloaded_identifier : identifier { $$ = $1; - $$->params = $0.params; $$->type = $0.type; - $$ = function_symbol ($$, $0.is_overload, 1); + if ($$->type->type != ev_field) { + $$ = function_symbol ($$, $0.is_overload, 1); + $$->params = $0.params; + } } ; @@ -849,10 +853,23 @@ non_code_func { build_builtin_function ($0, $3, 0); } + | '=' fexpr + { + symbol_t *sym = $0; + specifier_t spec = $-1; + initialize_def (sym, sym->type, $2, current_symtab->space, + spec.storage); + } | /* emtpy */ { symbol_t *sym = $0; - make_function (sym, 0, sym->table->space, current_storage); + specifier_t 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); + } } ;