From bfb7c936aa9ba5fe93c9923af1f1a8dc2deacf22 Mon Sep 17 00:00:00 2001 From: acqn Date: Tue, 30 Mar 2021 16:47:57 +0800 Subject: [PATCH] Preparation for constness-correction. --- src/cc65/expr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index b0ebbf191..64980aceb 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -4094,7 +4094,7 @@ static void hieQuest (ExprDesc* Expr) /* Get common type */ - ResultType = ArithmeticConvert (Expr2.Type, Expr3.Type); + ResultType = TypeDup (ArithmeticConvert (Expr2.Type, Expr3.Type)); /* Convert the third expression to this type if needed */ TypeConversion (&Expr3, ResultType); @@ -4138,22 +4138,22 @@ static void hieQuest (ExprDesc* Expr) } } else if (IsClassPtr (Expr2.Type) && Expr3IsNULL) { /* Result type is pointer, no cast needed */ - ResultType = Expr2.Type; + ResultType = TypeDup (Expr2.Type); } else if (Expr2IsNULL && IsClassPtr (Expr3.Type)) { /* Result type is pointer, no cast needed */ - ResultType = Expr3.Type; + ResultType = TypeDup (Expr3.Type); } else if (IsTypeVoid (Expr2.Type) && IsTypeVoid (Expr3.Type)) { /* Result type is void */ - ResultType = type_void; + ResultType = TypeDup (type_void); } else { if (IsClassStruct (Expr2.Type) && IsClassStruct (Expr3.Type) && TypeCmp (Expr2.Type, Expr3.Type).C == TC_IDENTICAL) { /* Result type is struct/union */ - ResultType = Expr2.Type; + ResultType = TypeDup (Expr2.Type); } else { TypeCompatibilityDiagnostic (Expr2.Type, Expr3.Type, 1, "Incompatible types in ternary '%s' with '%s'"); - ResultType = Expr2.Type; /* Doesn't matter here */ + ResultType = TypeDup (Expr2.Type); /* Doesn't matter here */ } }