]> git.sur5r.net Git - cc65/blobdiff - src/cc65/loadexpr.c
Changed names of the pragmas to be identical to the corresponding command line
[cc65] / src / cc65 / loadexpr.c
index 8e7f83b76177dc87a55d25750d945d96fb4750b6..fd09a4d7f7fac20aaa7a53afbe17b6f04c16e133 100644 (file)
@@ -95,8 +95,16 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
 {
     if (ED_IsLVal (Expr)) {
 
-               /* Dereferenced lvalue */
-               Flags |= TypeOf (Expr->Type);
+               /* Dereferenced lvalue. If this is a bit field its type is unsigned.
+         * But if the field is completely contained in the lower byte, we will
+         * 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;
+        } else {
+            Flags |= TypeOf (Expr->Type);
+        }
        if (ED_NeedsTest (Expr)) {
            Flags |= CF_TEST;
        }