mirror of
https://github.com/ZDoom/acc.git
synced 2025-03-13 03:42:17 +00:00
Fix constant || and && evaluation
- When SendExprCommand() evaluates constant expressions for || and &&, it must explicitly pop both operands off the stack before pushing the result. The compiler will do normal short-circuiting here, so if it only needs one value to determine the result, only one would be popped off the stack.
This commit is contained in:
parent
1722d11fe8
commit
3a5bedf702
1 changed files with 7 additions and 3 deletions
10
parse.c
10
parse.c
|
@ -3771,7 +3771,7 @@ static void ConstExprFactor(void)
|
||||||
|
|
||||||
static void SendExprCommand(pcd_t pcd)
|
static void SendExprCommand(pcd_t pcd)
|
||||||
{
|
{
|
||||||
int operand2;
|
int operand1, operand2;
|
||||||
|
|
||||||
if(ConstantExpression == NO)
|
if(ConstantExpression == NO)
|
||||||
{
|
{
|
||||||
|
@ -3821,10 +3821,14 @@ static void SendExprCommand(pcd_t pcd)
|
||||||
PushExStk(PopExStk() < operand2);
|
PushExStk(PopExStk() < operand2);
|
||||||
break;
|
break;
|
||||||
case PCD_ANDLOGICAL:
|
case PCD_ANDLOGICAL:
|
||||||
PushExStk(PopExStk() && PopExStk());
|
operand2 = PopExStk();
|
||||||
|
operand1 = PopExStk();
|
||||||
|
PushExStk(operand1 && operand2);
|
||||||
break;
|
break;
|
||||||
case PCD_ORLOGICAL:
|
case PCD_ORLOGICAL:
|
||||||
PushExStk(PopExStk() || PopExStk());
|
operand2 = PopExStk();
|
||||||
|
operand1 = PopExStk();
|
||||||
|
PushExStk(operand1 || operand2);
|
||||||
break;
|
break;
|
||||||
case PCD_ANDBITWISE:
|
case PCD_ANDBITWISE:
|
||||||
PushExStk(PopExStk()&PopExStk());
|
PushExStk(PopExStk()&PopExStk());
|
||||||
|
|
Loading…
Reference in a new issue