default-initialization of bitfields
commit5c6356ff8e8ad57c8d5ad8220d665dfba02290cf
authorherman ten brugge <hermantenbrugge@home.nl>
Fri, 18 Sep 2020 17:20:57 +0000 (18 19:20 +0200)
committerherman ten brugge <hermantenbrugge@home.nl>
Fri, 18 Sep 2020 17:20:57 +0000 (18 19:20 +0200)
tree90438424a7e413a2bd2a5e583565e934ad5266ad
parent6d819d7267d3797fb456103e21d59835c8958a19
default-initialization of bitfields

The code:

struct bf_SS {unsigned int bit:1,bits31:31; };
void func(void) {
  struct bf_SS bf_finit = { .bit = 1 };
}

will not init bits31 to 0.

tccgen.c:
- check_bf: New function to check if bitfield is present in struct/union
- decl_initializer: Call check_bf and set value to 0 is bitfield found

tests/tcctest.c:
- Add struct bitfield test code
tccgen.c
tests/tcctest.c