From 7a315b4a893393709e0cba381f889ccafaaee798 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 19 Feb 2020 10:50:15 +0900 Subject: [PATCH] Fix storage class for for-loop declarations Getting "i redeclared" when i was declared in a for loop in two different functions was a tad unexpected. --- tools/qfcc/source/qc-parse.y | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index a2bbf1c03..a71563abb 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -153,7 +153,7 @@ int yylex (void); %token PROTECTED PROTOCOL PUBLIC SELECTOR REFERENCE SELF THIS %type optional_specifiers specifiers local_specifiers -%type storage_class save_storage +%type storage_class save_storage set_spec_storage %type type_specifier type_specifier_or_storage_class %type type @@ -349,6 +349,14 @@ save_storage } ; +set_spec_storage + : /* emtpy */ + { + $$ = $0; + $$.storage = current_storage; + } + ; + function_body : optional_state_expr { @@ -1229,7 +1237,7 @@ switch_block opt_init : cexpr - | type init_var_decl_list { $$ = $2; } + | type set_spec_storage init_var_decl_list { $$ = $3; } | /* empty */ { $$ = 0;