Error ("Negative width in bit-field");
return -1;
}
- if (Expr.IVal > INT_BITS) {
+ if (Expr.IVal > (int) INT_BITS) {
Error ("Width of bit-field exceeds its type");
return -1;
}
UnionSize = FieldSize;
}
- /* Add a field entry to the table */
+ /* Add a field entry to the table. */
if (FieldWidth > 0) {
AddBitField (Decl.Ident, 0, 0, FieldWidth);
} else {
* with width zero, align the struct to the next member
*/
if (BitOffs > 0) {
- if (FieldWidth <= 0 || (BitOffs + FieldWidth) > INT_BITS) {
+ if (FieldWidth <= 0 || (BitOffs + FieldWidth) > (int) INT_BITS) {
StructSize += SIZEOF_INT;
BitOffs = 0;
}
/* Byte offset of this member is the current struct size plus any
* full bytes from the bit offset in case of bit-fields.
*/
- Offs = StructSize + (BitOffs >> 3);
+ Offs = StructSize + (BitOffs / CHAR_BITS);
/* Check if this field is a flexible array member, and
* calculate the size of the field.
/* Add a field entry to the table */
if (FieldWidth > 0) {
- AddBitField (Decl.Ident, Offs, BitOffs & 0x07, FieldWidth);
+ AddBitField (Decl.Ident, Offs, BitOffs % CHAR_BITS, FieldWidth);
BitOffs += FieldWidth;
} else {
AddLocalSym (Decl.Ident, Decl.Type, SC_STRUCTFIELD, Offs);
/* If we have bits from bit-fields left, add them to the size. */
if (BitOffs > 0) {
- StructSize += ((BitOffs + CHAR_BITS - 1) >> 3);
+ StructSize += ((BitOffs + CHAR_BITS - 1) / CHAR_BITS);
}
/* Skip the closing brace */