Fixed local variables shadowing global functions
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 3 Sep 2026 04:48:30 +0000 (05:48 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 3 Sep 2026 04:48:30 +0000 (05:48 +0100)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index 6fee090b78ef13bf3c9a65abebe04a88621563a0..7177be4d17c95b72733b54b8faf3a16c0c4409a8 100644 (file)
--- 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 6b0ad1a8f7139bc0298ee54eaf73b8d63450b7d7..855658733cd469ffabb1f629a2b6bf9e98087c8b 100644 (file)
--- 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))) {
         
             {