From 23795044498cce8f4b821c910f17db33445f99bd Mon Sep 17 00:00:00 2001 From: acqn Date: Mon, 31 Aug 2020 20:31:54 +0800 Subject: [PATCH] Fixed AND/OR in certain cases where the 'E_NEED_TEST' flag set for usage only in subexpressions should be cleared. --- src/cc65/expr.c | 6 ++++++ src/cc65/exprdesc.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 38df16faf..4071728ac 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -3223,6 +3223,9 @@ static int hieAnd (ExprDesc* Expr, unsigned* TrueLab, int* TrueLabAllocated) /* Load the value */ LoadExpr (CF_FORCECHAR, Expr); + /* Clear the test flag */ + ED_RequireNoTest (Expr); + /* Remember that the jump is used */ HasFalseJump = 1; @@ -3356,6 +3359,9 @@ static void hieOr (ExprDesc *Expr) /* Get first expr */ LoadExpr (CF_FORCECHAR, Expr); + /* Clear the test flag */ + ED_RequireNoTest (Expr); + if (HasTrueJump == 0) { /* Get a label that we will use for true expressions */ TrueLab = GetLocalLabel(); diff --git a/src/cc65/exprdesc.h b/src/cc65/exprdesc.h index f04be6a8d..c435b3c38 100644 --- a/src/cc65/exprdesc.h +++ b/src/cc65/exprdesc.h @@ -364,6 +364,16 @@ INLINE void ED_RequireTest (ExprDesc* Expr) # define ED_RequireTest(Expr) do { (Expr)->Flags |= E_NEED_TEST; } while (0) #endif +#if defined(HAVE_INLINE) +INLINE void ED_RequireNoTest (ExprDesc* Expr) +/* Mark the expression not for a test. */ +{ + Expr->Flags &= ~E_NEED_TEST; +} +#else +# define ED_RequireNoTest(Expr) do { (Expr)->Flags &= ~E_NEED_TEST; } while (0) +#endif + #if defined(HAVE_INLINE) INLINE int ED_GetNeeds (const ExprDesc* Expr) /* Get flags about what the expression needs. */