From: cuz Date: Wed, 10 Jul 2002 21:04:02 +0000 (+0000) Subject: Fixed/worked around a bug X-Git-Tag: V2.12.0~2282 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f93eb903baa1b7cd828b0ecff06723198b70e3fc;p=cc65 Fixed/worked around a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@1343 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/expr.c b/src/cc65/expr.c index c5e308163..53577e39d 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -240,21 +240,21 @@ unsigned assignadjust (type* lhst, ExprDesc* rhs) * - the lhs pointer is a void pointer. */ if (!IsTypeVoid (Indirect (lhst)) && !IsTypeVoid (Indirect (rhst))) { - /* Compare the types */ - switch (TypeCmp (lhst, rhst)) { + /* Compare the types */ + switch (TypeCmp (lhst, rhst)) { - case TC_INCOMPATIBLE: - Error ("Incompatible pointer types"); - break; + case TC_INCOMPATIBLE: + Error ("Incompatible pointer types"); + break; - case TC_QUAL_DIFF: - Error ("Pointer types differ in type qualifiers"); - break; + case TC_QUAL_DIFF: + Error ("Pointer types differ in type qualifiers"); + break; - default: - /* Ok */ - break; - } + default: + /* Ok */ + break; + } } } else if (IsClassInt (rhst)) { /* Int to pointer assignment is valid only for constant zero */ @@ -279,7 +279,7 @@ unsigned assignadjust (type* lhst, ExprDesc* rhs) return CF_INT; } - + void DefineData (ExprDesc* Expr) /* Output a data definition for the given expression */ @@ -2947,8 +2947,10 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *lval, int k) lflags |= TypeOf (lval->Type) | CF_FORCECHAR; rflags |= TypeOf (lval2.Type); - /* Adjust the rhs to the lhs */ - g_typeadjust (lflags, rflags); + /* Adjust the rhs to the lhs. To avoid manipulation of the TOS, mark + * the lhs as const. + */ + g_typeadjust (lflags | CF_CONST, rflags); /* Output apropriate code */ if (lval->Flags & E_MGLOBAL) {