pycparser icon indicating copy to clipboard operation
pycparser copied to clipboard

Labels at the end of compound statements

Open nxmaintainer opened this issue 2 years ago • 1 comments

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.

nxmaintainer avatar Dec 30 '22 19:12 nxmaintainer

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

eliben avatar Jan 07 '23 12:01 eliben