diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 153cc2165..c8292f0e1 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -152,7 +152,7 @@ int yylex (void); %token PROTECTED PROTOCOL PUBLIC SELECTOR REFERENCE SELF THIS %type optional_specifiers specifiers local_specifiers -%type storage_class +%type storage_class save_storage %type type_specifier type_specifier_or_storage_class %type type @@ -297,7 +297,6 @@ external_def_list : /* empty */ { current_symtab = pr.symtab; - current_storage = st_global; } | external_def_list external_def | external_def_list obj_def @@ -325,8 +324,21 @@ external_def } function_def_list | optional_specifiers function_decl function_body - | storage_class '{' { current_storage = $1.storage; } - external_def_list '}' ';' { current_storage = st_global; } + | storage_class '{' save_storage + { + current_storage = $1.storage; + } + external_def_list '}' ';' + { + current_storage = $3.storage; + } + ; + +save_storage + : /* emtpy */ + { + $$.storage = current_storage; + } ; function_body @@ -337,6 +349,7 @@ function_body sym->type = find_type (append_type (sym->type, $-1.type)); $$ = function_symbol (sym, $-1.is_overload, 1); } + save_storage { $$ = current_symtab; current_func = begin_function ($2, 0, current_symtab, 0); @@ -345,9 +358,9 @@ function_body } compound_statement { - build_code_function ($2, $1, $4); - current_symtab = $3; - current_storage = st_global; + build_code_function ($2, $1, $5); + current_symtab = $4; + current_storage = $3.storage; current_func = 0; } | '=' '#' expr ';' @@ -421,6 +434,11 @@ storage_class optional_specifiers : specifiers + { + $$ = $1; + if (!$$.storage) + $$.storage = current_storage; + } | /* empty */ { $$ = make_spec (0, current_storage, 0, 0); @@ -906,6 +924,7 @@ non_code_func code_func : '=' optional_state_expr + save_storage { $$ = current_symtab; current_func = begin_function ($0, 0, current_symtab, 0); @@ -914,9 +933,9 @@ code_func } compound_statement { - build_code_function ($0, $2, $4); - current_symtab = $3; - current_storage = st_global; + build_code_function ($0, $2, $5); + current_symtab = $4; + current_storage = $3.storage; current_func = 0; } ; @@ -1548,6 +1567,7 @@ methoddef $2 = method = class_find_method (current_class, method); $$ = method_symbol (current_class, method); } + save_storage { method_t *method = $2; const char *nicename = method_name (method); @@ -1567,9 +1587,9 @@ methoddef } compound_statement { - build_code_function ($4, $3, $6); - current_symtab = $5; - current_storage = st_global; + build_code_function ($4, $3, $7); + current_symtab = $6; + current_storage = $5.storage; current_func = 0; } | ci methoddecl '=' '#' const ';'