eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.21k stars 611 forks source link

Labels at the end of compound statements #484

Open nxmaintainer opened 1 year ago

nxmaintainer commented 1 year ago

This sample would be incorrect in C++, iirc, but it is valid in modern C (sorry, I can't find the standard version when it was added first):

int main(void) {
    switch(0) {
        case 0: {
            if (1) {
                goto label;
            }
        label:
        }
    }
}

gcc works properly even w/ -std=c99 (clang fails, but looks like it's possible to fix w/ proper flags), pycparser fails with ParseError: before: }

@eliben I'm not sure if you want to support this feature, but I'd really appreciate an advice. Will try to workaround during the preprocessing stage, label:; should help here, probably.

eliben commented 1 year ago

I'll be happy to review a concrete PR that fixes this