From dc878dbb4c986427bdb2a01d23f6c69a9e3f0316 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 7 Oct 2024 09:55:21 +0900 Subject: [PATCH] [qfcc] Skip scope creation for function bodies Since begin_function creates the parameter and locals scopes, there's no need for another scope for the function body. This fixes the detection of shadowed parameters for Ruamoko and QuakeC. --- tools/qfcc/source/qc-parse.y | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index a9f79bc0f..ea3837b7e 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -216,7 +216,7 @@ int yylex (YYSTYPE *yylval, YYLTYPE *yylloc); %type method_optional_state_expr optional_state_expr %type texpr vector_expr %type statement -%type statements compound_statement +%type statements compound_statement compound_statement_ns %type else bool_label break_label continue_label %type unary_expr ident_expr cast_expr %type arg_list @@ -852,7 +852,7 @@ qc_code_func current_storage = sc_local; $1 = sym; } - compound_statement + compound_statement_ns { build_code_function ($1, $3, $6); current_symtab = $5.symtab; @@ -1164,7 +1164,7 @@ function_body current_symtab = current_func->locals; current_storage = sc_local; } - compound_statement + compound_statement_ns { build_code_function ($2, $1, $5); current_symtab = $4.symtab; @@ -1787,6 +1787,10 @@ compound_statement : '{' push_scope flush_dag statements '}' pop_scope flush_dag { $$ = $4; } ; +compound_statement_ns + : '{' flush_dag statements '}' flush_dag { $$ = $3; } + ; + statements : /*empty*/ { @@ -2536,7 +2540,7 @@ methoddef current_symtab = current_func->locals; current_storage = sc_local; } - compound_statement + compound_statement_ns { build_code_function ($4, $3, $7); current_symtab = $6.symtab;