From: Robert Pengelly Date: Thu, 3 Sep 2026 04:48:30 +0000 (+0100) Subject: Fixed local variables shadowing global functions X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=21a2e3a8036477a826868ff295bb7cf4e7b1a571;p=scc.git Fixed local variables shadowing global functions --- diff --git a/amd64.c b/amd64.c index 6fee090..7177be4 100644 --- a/amd64.c +++ b/amd64.c @@ -21043,10 +21043,15 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { const char *name_start = tok.start, *name_caret = tok.caret; unsigned long name_line = get_line_number (); + struct local_symbol *visible_local; struct local_symbol *src; + + int name_is_function_designator; int postfix_incdec = 0; - int name_is_function_designator = token_identifier_is_function_call_rhs_now (); + visible_local = peek_local_symbol (name); + name_is_function_designator = token_identifier_is_function_call_rhs_now (); + get_token (); /* @@ -21058,7 +21063,7 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { * * store the first bytes of msdos_probe instead of its address. */ - if (tok.kind != TOK_LPAREN && (name_is_function_designator || (find_global_symbol (name) >= 0 && get_global_symbol_kind (name) == GLOBAL_SYMBOL_FUNCTION))) { + if (!visible_local && tok.kind != TOK_LPAREN && (name_is_function_designator || (find_global_symbol (name) >= 0 && get_global_symbol_kind (name) == GLOBAL_SYMBOL_FUNCTION))) { { diff --git a/i386.c b/i386.c index 6b0ad1a..8556587 100644 --- a/i386.c +++ b/i386.c @@ -19744,10 +19744,15 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { const char *name_start = tok.start, *name_caret = tok.caret; unsigned long name_line = get_line_number (); + struct local_symbol *visible_local; struct local_symbol *src; + + int name_is_function_designator; int postfix_incdec = 0; - int name_is_function_designator = token_identifier_is_function_call_rhs_now (); + visible_local = peek_local_symbol (name); + name_is_function_designator = token_identifier_is_function_call_rhs_now (); + get_token (); /* @@ -19763,7 +19768,7 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { * * which stores bytes like 55 89 e5 81 as the callback pointer. */ - if (tok.kind != TOK_LPAREN && (name_is_function_designator || (find_global_symbol (name) >= 0 && get_global_symbol_kind (name) == GLOBAL_SYMBOL_FUNCTION))) { + if (!visible_local && tok.kind != TOK_LPAREN && (name_is_function_designator || (find_global_symbol (name) >= 0 && get_global_symbol_kind (name) == GLOBAL_SYMBOL_FUNCTION))) { {