]> git.sur5r.net Git - cc65/blobdiff - src/cc65/loadexpr.c
Fixed two compiler warnings.
[cc65] / src / cc65 / loadexpr.c
index fd09a4d7f7fac20aaa7a53afbe17b6f04c16e133..99c5684d16f4242245b53b969377fb915ca31a24 100644 (file)
@@ -100,8 +100,9 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
          * throw away the high byte anyway and may therefore load just the
          * low byte.
          */
-        if (ED_IsBitField (Expr) && Expr->BitOffs + Expr->BitWidth <= CHAR_BITS) {
-            Flags |= CF_CHAR | CF_UNSIGNED;
+        if (ED_IsBitField (Expr)) {
+            Flags |= (Expr->BitOffs + Expr->BitWidth <= CHAR_BITS)? CF_CHAR : CF_INT;
+            Flags |= CF_UNSIGNED;
         } else {
             Flags |= TypeOf (Expr->Type);
         }
@@ -161,8 +162,11 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
             unsigned F = CF_INT | CF_UNSIGNED | CF_CONST | (Flags & CF_TEST);
             /* Shift right by the bit offset */
             g_asr (F, Expr->BitOffs);
-            /* And by the width */
-            g_and (F, (0x0001U << Expr->BitWidth) - 1U);
+            /* And by the width if the field doesn't end on an int boundary */
+            if (Expr->BitOffs + Expr->BitWidth != CHAR_BITS &&
+                Expr->BitOffs + Expr->BitWidth != INT_BITS) {
+                g_and (F, (0x0001U << Expr->BitWidth) - 1U);
+            }
         }
 
         /* Expression was tested */