From bb9c2032224a9abd034f8fcb17699048ac351e00 Mon Sep 17 00:00:00 2001 From: acqn Date: Sat, 15 Aug 2020 07:53:28 +0800 Subject: [PATCH] Fixed integer promotion of unary operations. --- src/cc65/expr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 12a0c0b57..9f7902284 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1856,8 +1856,8 @@ static void UnaryOp (ExprDesc* Expr) /* Value is not constant */ LoadExpr (CF_NONE, Expr); - /* Get the type of the expression */ - Flags = TypeOf (Expr->Type); + /* Adjust the type of the value */ + Flags = g_typeadjust (TypeOf (Expr->Type), TypeOf (type_int) | CF_CONST); /* Handle the operation */ switch (Tok) { @@ -1870,6 +1870,9 @@ static void UnaryOp (ExprDesc* Expr) /* The result is an rvalue in the primary */ ED_FinalizeRValLoad (Expr); } + + /* Adjust the type of the expression */ + Expr->Type = IntPromotion (Expr->Type); }