eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.24k stars 609 forks source link

Cast an empty compound literal raises ParserError #503

Open nxmaintainer opened 1 year ago

nxmaintainer commented 1 year ago

(uint8_t[16]){} (looks like it's C99 compliant statement) raises a ParserError (before: }), (uint8_t[16]){0} doesn't (it's a different logic, but just to test the origin of the issue)

A little bit more context (obfuscated but should be reproducible), just in case:

uint8_t test_a() {
  return test_b((uint8_t[16]){});
}

uint8_t test_b(const uint8_t param[16]) {
  return param[0];
}

It's difficult for me to debug the C parser in this project, I'd be happy if @eliben or other folks can point me in what direction to dig to fix this, I'd be happy to provide a PR

JulianKemmerer commented 1 year ago

Oooo you can use uint8_t[16] as a type in modern C? (fixed size arrays)

I've been wanting to do stuff like

uint8_t[16] return_a_16_byte_array_func(...)
{
...
}

for a while...