From ea0c634e12cb122113a9b97eb66a0efbda082aa6 Mon Sep 17 00:00:00 2001 From: acqn Date: Tue, 23 Feb 2021 17:39:02 +0800 Subject: [PATCH] Improved codegen for unsigned char type comparison with numeric constants. --- src/cc65/expr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 083d1dc99..66c633d2e 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -2845,7 +2845,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */ } /* Determine the type of the operation. */ - if (IsTypeChar (Expr->Type) && rconst && RightSigned) { + if (IsTypeChar (Expr->Type) && rconst && (!LeftSigned || RightSigned)) { /* Left side is unsigned char, right side is constant. ** Determine the minimum and maximum values @@ -2923,7 +2923,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */ ** since the right side constant is in a valid range. */ flags |= (CF_CHAR | CF_FORCECHAR); - if (!LeftSigned) { + if (!LeftSigned || !RightSigned) { flags |= CF_UNSIGNED; }