1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00

The 'E_NEED_TEST' flag shouldn't be overwritten when loading the expression result.

This commit is contained in:
acqn 2020-08-31 02:30:12 +08:00
parent d87846e1e1
commit 74def4608a
2 changed files with 11 additions and 6 deletions

View File

@ -3460,11 +3460,6 @@ static void hieQuest (ExprDesc* Expr)
int Expr3IsNULL; /* Expression 3 is a NULL pointer */
Type* ResultType; /* Type of result */
ED_Init (&Expr2);
Expr2.Flags = Expr->Flags & E_MASK_KEEP_RESULT;
ED_Init (&Expr3);
Expr3.Flags = Expr->Flags & E_MASK_KEEP_RESULT;
/* Call the lower level eval routine */
if (Preprocessing) {
ExprWithCheck (hieOrPP, Expr);
@ -3476,6 +3471,13 @@ static void hieQuest (ExprDesc* Expr)
if (CurTok.Tok == TOK_QUEST) {
int ConstantCond = ED_IsConstAbsInt (Expr);
unsigned Flags = Expr->Flags & E_MASK_KEEP_RESULT;
ED_Init (&Expr2);
Expr2.Flags = Flags;
ED_Init (&Expr3);
Expr3.Flags = Flags;
NextToken ();
if (!ConstantCond) {
@ -3616,7 +3618,10 @@ static void hieQuest (ExprDesc* Expr)
if (!ConstantCond) {
/* Define the final label */
g_defcodelabel (TrueLab);
/* Set up the result expression type */
ED_FinalizeRValLoad (Expr);
/* Restore the original evaluation flags */
Expr->Flags = (Expr->Flags & ~E_MASK_KEEP_RESULT) | Flags;
} else {
if (Expr->IVal != 0) {
*Expr = Expr2;

View File

@ -266,7 +266,7 @@ ExprDesc* ED_FinalizeRValLoad (ExprDesc* Expr)
{
Expr->Sym = 0;
Expr->Flags &= ~(E_MASK_LOC | E_MASK_RTYPE | E_BITFIELD | E_ADDRESS_OF);
Expr->Flags &= ~(E_NEED_TEST | E_CC_SET);
Expr->Flags &= ~E_CC_SET;
Expr->Flags |= (E_LOC_PRIMARY | E_RTYPE_RVAL);
Expr->Name = 0;
Expr->IVal = 0; /* No offset */