1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

Improved code for bit fields.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4097 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-08-31 15:11:32 +00:00
parent dc678e8dcb
commit 7983009e06

View 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;
}