From: Robert Pengelly Date: Tue, 17 Nov 2026 04:51:50 +0000 (+0000) Subject: i386/amd64: Fix arithmetic operations in function-call conditions X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=a58a898dc8efc6608bafd566b3e000595b967e82;p=scc.git i386/amd64: Fix arithmetic operations in function-call conditions --- diff --git a/amd64.c b/amd64.c index 8ed68af..934ebf9 100644 --- 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 25db397..01cece2 100644 --- 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;