Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect removal of parentheses after the comma operator followed by a compound statement #560

Open
kousuke3021 opened this issue Dec 4, 2024 · 1 comment

Comments

@kousuke3021
Copy link

kousuke3021 commented Dec 4, 2024

When converting the following code into an Abstract Syntax Tree (AST) and generating code from it using pycparser, the parentheses surrounding a compound statement are removed, resulting in code that fails to compile due to a syntax error.

void test(){
    (sizeof (0), ({ if (0) ; else ; }));
}

The generated code appears as follows:

void test(){
    sizeof (0), { if (0) ; else ; };
}
@eliben
Copy link
Owner

eliben commented Dec 4, 2024

PRs to fix this are welcome.

Please note that the ability to generate C code back from the AST is not considered a critical capability of pycparser; while I'll accept PRs for it, it's generally lower priority than the parsing part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants