From 7a1a9e3f2d75566322ed3af85d679a862d967366 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 7 Feb 2011 21:41:03 +0900 Subject: [PATCH] Better handling of the current storage for function scopes. --- tools/qfcc/source/qc-parse.y | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 4d0219b75..cd59aaeb5 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -330,11 +330,13 @@ function_body $$ = current_symtab; current_func = begin_function (sym, 0, current_symtab); current_symtab = current_func->symtab; + current_storage = st_local; } compound_statement { build_code_function ($0, $1, $3); current_symtab = $2; + current_storage = st_global; } | '=' '#' expr ';' { @@ -703,8 +705,8 @@ array_decl ; local_specifiers - : LOCAL specifiers { current_storage = st_local; $$ = $2; } - | specifiers { current_storage = st_local; $$ = $1; } + : LOCAL specifiers { $$ = $2; } + | specifiers { $$ = $1; } ; /* param_scope @@ -802,16 +804,18 @@ non_code_func ; code_func - : '=' + : '=' optional_state_expr { $$ = current_symtab; current_func = begin_function ($0, 0, current_symtab); current_symtab = current_func->symtab; + current_storage = st_local; } - optional_state_expr compound_statement + compound_statement { - build_code_function ($0, $3, $4); - current_symtab = $2; + build_code_function ($0, $2, $4); + current_symtab = $3; + current_storage = st_global; } ; @@ -905,7 +909,6 @@ local_def { $$ = local_expr; local_expr = 0; - current_storage = st_local; } statement @@ -1451,11 +1454,13 @@ methoddef current_func->symtab); method->def = sym->s.func->def; current_symtab = current_func->symtab; + current_storage = st_local; } compound_statement { build_code_function ($4, $3, $6); current_symtab = $5; + current_storage = st_global; } | ci methoddecl '=' '#' const ';' {