Fix address-of aggregate member arguments
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 6 Oct 2026 04:05:36 +0000 (05:05 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 6 Oct 2026 04:05:36 +0000 (05:05 +0100)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index 714f283650a8cc4870ca9418d4cbfbb1d3c527cb..74319d6be08951303bda354132711e18b5ee8be6 100644 (file)
--- a/amd64.c
+++ b/amd64.c
@@ -20351,6 +20351,8 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) {
             
             }
             
+            set_rhs_last_pointer_info (1, current_object_size);
+            
             free (name);
             return;
         
@@ -25158,8 +25160,11 @@ static int emit_push_global_aggregate_argument_now (const char *name) {
 static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result_reg) {
 
     int argc = 0;
-    int arg_bytes;
+    
+    int arg_starts_address_of;
     int arg_is_floating;
+    int arg_bytes;
+    
     int i;
     int ch;
     
@@ -25198,6 +25203,8 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result
     
         for (;;) {
         
+            arg_starts_address_of = tok.kind == TOK_AMPER;
+            
             arg_saved_ofp = 0;
             arg_tmp_ofp = 0;
             arg_is_floating = 0;
@@ -25334,12 +25341,12 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result
                 
                 if (state->ofp) {
                 
-                    if (!arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes);
                     
-                    } else if (!arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes);
@@ -27020,6 +27027,7 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg,
     int total_arg_bytes = 0;
     
     int arg_is_floating, ch, i;
+    int arg_starts_address_of;
     int arg_bytes;
     
     int saved_arg_assignment32_stop_before_condition_operator;
@@ -27120,6 +27128,8 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg,
     
         for (;;) {
         
+            arg_starts_address_of = tok.kind == TOK_AMPER;
+            
             arg_saved_ofp = 0;
             arg_tmp_ofp = 0;
             
@@ -27276,12 +27286,12 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg,
                          * slot according to the AMD64 calling convention.
                          */
                     
-                    } else if (!use_inline && !arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes);
                     
-                    } else if (!use_inline && !arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes);
diff --git a/i386.c b/i386.c
index 9851bce42482dd23f7538a3239a64e0abcb7f78a..fbf3bf2b7a69fd24e3d82596d92571a84e7e0847 100644 (file)
--- a/i386.c
+++ b/i386.c
@@ -19109,6 +19109,8 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) {
             
             }
             
+            set_rhs_last_pointer_info (1, current_object_size);
+            
             free (name);
             return;
         
@@ -23714,10 +23716,13 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result
 
     enum token_kind saved_calling_convention = postfix_member_calling_convention;
     
-    int argc = 0;
     int total_arg_bytes = 0;
-    int arg_bytes;
+    int argc = 0;
+    
+    int arg_starts_address_of;
     int arg_is_floating;
+    int arg_bytes;
+    
     int i;
     int ch;
     
@@ -23746,6 +23751,8 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result
     
         for (;;) {
         
+            arg_starts_address_of = tok.kind == TOK_AMPER;
+            
             arg_saved_ofp = 0;
             arg_tmp_ofp = 0;
             
@@ -23837,12 +23844,12 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result
                         emit_push_reg_now ("edx");
                         emit_push_reg_now ("eax");
                     
-                    } else if (!arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes);
                     
-                    } else if (!arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes);
@@ -24235,6 +24242,7 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg,
     int total_arg_bytes = 0;
     
     int arg_is_floating, ch, i;
+    int arg_starts_address_of;
     int arg_bytes;
     
     int saved_arg_assignment32_stop_before_condition_operator;
@@ -24325,6 +24333,8 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg,
     
         for (;;) {
         
+            arg_starts_address_of = tok.kind == TOK_AMPER;
+            
             arg_saved_ofp = 0;
             arg_tmp_ofp = 0;
             
@@ -24495,12 +24505,12 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg,
                         emit_push_reg_now ("edx");
                         emit_push_reg_now ("eax");
                     
-                    } else if (!use_inline && !arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes);
                     
-                    } else if (!use_inline && !arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
+                    } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) {
                     
                         arg_bytes = postfix_member_size;
                         emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes);