Fix bitfields with non-int types and in unions
commit0748a69f2579b58c4f34392f7dd9597614a7d9b1
authorDaniel Glöckner <daniel-gl@gmx.net>
Thu, 11 Sep 2008 17:18:58 +0000 (11 19:18 +0200)
committerDaniel Glöckner <daniel-gl@gmx.net>
Thu, 11 Sep 2008 17:18:58 +0000 (11 19:18 +0200)
tree8161da59aa7f5cd764e286967ada457dda285383
parentdd37b57f2c7e96ba77cc3b9b1e0679ccfc40608f
Fix bitfields with non-int types and in unions

The ISO C draft allow only signed/unsigned int and _Bool as base type
for bitfields. TinyCC ever since allowed a wider range of types, but
there were many bugs that shifted values when they shouldn't, etc..
The patch introduces a restriction to the layout of bitfields with
mixed types that makes it incompatible with GCC. In

struct {
  typeA x:1;
  typeB y:1;
};

y is combined with x in the same byte iff typeA is typeB (neglecting
signedness). This is done to avoid alignment issues and exceeding the
width of typeA.
tcc.c