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:
Randy Heit 2014-02-04 20:19:13 -06:00
parent 1722d11fe8
commit 3a5bedf702

10
parse.c
View file

@ -3771,7 +3771,7 @@ static void ConstExprFactor(void)
static void SendExprCommand(pcd_t pcd)
{
int operand2;
int operand1, operand2;
if(ConstantExpression == NO)
{
@ -3821,10 +3821,14 @@ static void SendExprCommand(pcd_t pcd)
PushExStk(PopExStk() < operand2);
break;
case PCD_ANDLOGICAL:
PushExStk(PopExStk() && PopExStk());
operand2 = PopExStk();
operand1 = PopExStk();
PushExStk(operand1 && operand2);
break;
case PCD_ORLOGICAL:
PushExStk(PopExStk() || PopExStk());
operand2 = PopExStk();
operand1 = PopExStk();
PushExStk(operand1 || operand2);
break;
case PCD_ANDBITWISE:
PushExStk(PopExStk()&PopExStk());