Fix member access after function calls in 64-bit expressions
authorRobert Pengelly <robertapengelly@hotmail.com>
Mon, 2 Nov 2026 08:17:52 +0000 (08:17 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Mon, 2 Nov 2026 08:17:52 +0000 (08:17 +0000)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index 577369031a0fa87130554a8cadf489a4bcc276eb..375bd545ca59a191cfc0c508db99f6e7512dcbd6 100644 (file)
--- a/amd64.c
+++ b/amd64.c
@@ -14128,6 +14128,23 @@ static void emit_load_assignment_rhs_to_pair (const char *lo, const char *hi) {
             
             }
             
+            if (tok.kind == TOK_ARROW || tok.kind == TOK_DOT) {
+            
+                postfix_copy_lvalue_size = get_global_symbol_pointed_size (name);
+                postfix_copy_lvalue_tag_name = get_global_symbol_tag_name (name);
+                
+                emit_apply_postfix_member_access_to_reg_now (lo);
+                
+                if (postfix_member_seen) {
+                
+                    if (postfix_member_size != (DATA_LLONG & 0x1f) || postfix_member_pointer_depth > 0) {
+                        emit_extend_pair_high_from_low (lo, hi, postfix_member_size, postfix_member_is_unsigned);
+                    }
+                
+                }
+            
+            }
+            
             free (name);
             return;
         
diff --git a/i386.c b/i386.c
index 2500b522ec53cd4cd12b54e0b13c220257d90f30..bddae241b98ef5924f6dd30aaa0d7b9a1bcdf6fc 100644 (file)
--- a/i386.c
+++ b/i386.c
@@ -12638,6 +12638,30 @@ static void emit_load_assignment_rhs_to_pair (const char *lo, const char *hi) {
             
             }
             
+            if (tok.kind == TOK_ARROW || tok.kind == TOK_DOT) {
+            
+                postfix_copy_lvalue_size = get_global_symbol_pointed_size (name);
+                postfix_copy_lvalue_tag_name = get_global_symbol_tag_name (name);
+                
+                emit_apply_postfix_member_access_to_reg_now (lo);
+                
+                if (postfix_member_seen) {
+                
+                    if (postfix_member_size == (DATA_LLONG & 0x1f) && postfix_member_pointer_depth == 0) {
+                    
+                        const char *addr_reg = (strcmp (lo, "ecx") != 0 && strcmp (hi, "ecx") != 0) ? "ecx" : "esi";
+                        
+                        emit_copy_reg_now (addr_reg, lo);
+                        emit_load_pair_from_deref_reg_now (lo, hi, addr_reg);
+                    
+                    } else {
+                        emit_extend_pair_high_from_low (lo, hi, postfix_member_size, postfix_member_is_unsigned);
+                    }
+                
+                }
+            
+            }
+            
             free (name);
             return;