Fix bitfields with non-int types and in unions
commit3783b335084ef69447c8703c7b9a94687d80b1cb
authorDaniel Glöckner <daniel-gl@gmx.net>
Thu, 11 Sep 2008 17:18:58 +0000 (11 19:18 +0200)
committergrischka <grischka>
Fri, 12 Sep 2008 20:23:01 +0000 (12 22:23 +0200)
tree5aa4461e311f71c876e0d26818f3a8d5cda3152e
parent43a34d354a6a3b0df07ed065adb050c0dda9abaa
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