]> git.sur5r.net Git - cc65/commitdiff
Fixed/worked around a bug
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 10 Jul 2002 21:04:02 +0000 (21:04 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 10 Jul 2002 21:04:02 +0000 (21:04 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1343 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/expr.c

index c5e308163974f5fe7b6c92a1eb45e6b87c088deb..53577e39d6aa3cf562b7910f8b1bf0f8c4c417ad 100644 (file)
@@ -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) {