Fixed repeated pointer dereferences
authorRobert Pengelly <robertapengelly@hotmail.com>
Fri, 4 Sep 2026 09:37:06 +0000 (10:37 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Fri, 4 Sep 2026 09:37:06 +0000 (10:37 +0100)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index 7177be4d17c95b72733b54b8faf3a16c0c4409a8..8dc62d1577a00edc3056d2aa4958a92ced303a51 100644 (file)
--- a/amd64.c
+++ b/amd64.c
@@ -12764,6 +12764,7 @@ static void emit_store_floating_member_to_addr_reg_now (const char *addr_reg, in
 static void emit_load_floating_rhs_expression_now (int result_size);
 static void emit_load_assignment_rhs_to_reg (const char *reg);
 
+static int source_starts_double_deref_at_now (const char *p);
 static int emit_load_deref_assignment_expression_to_reg_now (const char *reg);
 static int emit_statement_rhs_const32_to_rdx_if_possible (void);
 
@@ -13092,6 +13093,22 @@ static void emit_load_assignment_rhs_to_pair (const char *lo, const char *hi) {
     
     }
     
+    /*
+     * Repeated unary dereference belongs to the normal scalar operand parser.
+     * Let it consume the complete chain (*p, **pp, ***ppp, ...), then widen
+     * the resulting scalar value for the pair expression.  The old pair path
+     * consumed one '*' itself and therefore required the following token to be
+     * an identifier, rejecting every repeated-dereference expression.
+     */
+    if (tok.kind == TOK_STAR && source_starts_double_deref_at_now (tok.caret)) {
+    
+        emit_load_assignment_rhs_to_reg (lo);
+        
+        emit_extend_pair_high_from_low (lo, hi, DATA_INT & 0x1f, 1);
+        return;
+    
+    }
+    
     if (tok.kind == TOK_STAR) {
     
         char *name;
diff --git a/i386.c b/i386.c
index 855658733cd469ffabb1f629a2b6bf9e98087c8b..d24d3b4c4163e7780572127a6798ad0e5907a2c4 100644 (file)
--- a/i386.c
+++ b/i386.c
@@ -11356,6 +11356,7 @@ static void emit_store_floating_member_to_addr_reg_now (const char *addr_reg, in
 static void emit_load_floating_rhs_expression_now (int result_size);
 static void emit_load_assignment_rhs_to_reg (const char *reg);
 
+static int source_starts_double_deref_at_now (const char *p);
 static int emit_load_deref_assignment_expression_to_reg_now (const char *reg);
 static int emit_statement_rhs_const32_to_edx_if_possible (void);
 
@@ -11644,6 +11645,22 @@ static void emit_load_assignment_rhs_to_pair (const char *lo, const char *hi) {
     
     }
     
+    /*
+     * Repeated unary dereference belongs to the normal scalar operand parser.
+     * Let it consume the complete chain (*p, **pp, ***ppp, ...), then widen
+     * the resulting scalar value for the pair expression.  The old pair path
+     * consumed one '*' itself and therefore required the following token to be
+     * an identifier, rejecting every repeated-dereference expression.
+     */
+    if (tok.kind == TOK_STAR && source_starts_double_deref_at_now (tok.caret)) {
+    
+        emit_load_assignment_rhs_to_reg (lo);
+        
+        emit_extend_pair_high_from_low (lo, hi, DATA_INT & 0x1f, rhs_last_scalar_is_unsigned >= 0 ? rhs_last_scalar_is_unsigned : 0);
+        return;
+    
+    }
+    
     if (tok.kind == TOK_STAR) {
     
         char *name;