eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.26k stars 612 forks source link

Curly braces inside braced-group throws ParseError #519

Closed leventeBajczi closed 1 year ago

leventeBajczi commented 1 year ago

The following code compiles with gcc -std=c99, but pycparser throws a ParseError, complaining about the { token:

int main(){
    int a = ({1;});
}

Such constructs are used in some tasks of SV-COMP (example), and therefore pycparser cannot be used for such tasks.

Would it be possible to support such constructs in pycparser easily?

eliben commented 1 year ago

It seems like a GNU extension to me, which pycparser doesn't support. Are you sure this syntax is part of the ISO C standard?

leventeBajczi commented 1 year ago

Ah, my bad, I forgot to test with the -pedantic flag, which causes the error message warning: ISO C forbids braced-groups within expressions to appear. I guess this answers my original concern, so I'm closing the issue.