i386/amd64: Fix arithmetic operations in function-call conditions
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 17 Nov 2026 04:51:50 +0000 (04:51 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 17 Nov 2026 04:51:50 +0000 (04:51 +0000)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index 8ed68af71d17d646bb03fac1b5ec109998ce8015..934ebf9ce186abb4753a781f80782c42d869fc2d 100644 (file)
--- a/amd64.c
+++ b/amd64.c
@@ -38248,6 +38248,25 @@ static void emit_statement_jump_if_false (int label) {
         
         }
         
+        while (is_arithmetic_binary_operator (tok.kind)) {
+        
+            int prec = arithmetic_operator_precedence_now (tok.kind);
+            
+            op = tok.kind;
+            get_token ();
+            
+            emit_push_reg_now ("rax");
+            
+            if (emit_load_assignment_binary_expression_prec_to_reg ("rdx", prec + 1)) {
+                is_unsigned = 1;
+            }
+            
+            emit_pop_reg_now ("rax");
+            emit_assignment_binary_op (op, is_unsigned);
+        
+        }
+        
+        
         if (token_is_statement_compare_operator (tok.kind)) {
         
             op = tok.kind;
diff --git a/i386.c b/i386.c
index 25db397aae76fa1cf084a86625f5278b2a334be5..01cece29ebf3a43cc3480fc8fd3d2115e385ba24 100644 (file)
--- a/i386.c
+++ b/i386.c
@@ -36468,6 +36468,24 @@ static void emit_statement_jump_if_false (int label) {
         
         }
         
+        while (is_arithmetic_binary_operator (tok.kind)) {
+        
+            int prec = arithmetic_operator_precedence_now (tok.kind);
+            
+            op = tok.kind;
+            get_token ();
+            
+            emit_push_reg_now ("eax");
+            
+            if (emit_load_assignment_binary_expression_prec_to_reg ("edx", prec + 1)) {
+                is_unsigned = 1;
+            }
+            
+            emit_pop_reg_now ("eax");
+            emit_assignment_binary_op (op, is_unsigned);
+        
+        }
+        
         if (token_is_statement_compare_operator (tok.kind)) {
         
             op = tok.kind;