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

c-to-c breaks with multiple pragma in if/for/while without compound statement #479

Closed
ldore-ks opened this issue Nov 7, 2022 · 0 comments

Comments

@ldore-ks
Copy link

ldore-ks commented Nov 7, 2022

When parsing, then generating C, the following code:

int glob = 0;
void f(int test) {
  if (test)
    #pragma clang foo
    #pragma clang bar
    glob += 1; // <-- Only increment glob if test is not false
}

Gets transformed to:

int glob = 0;
void f(int test) {
  if (test) {
    #pragma foo
    #pragma bar
  }
  glob += 1; // <-- Always increment glob
}

Source input and output have different runtime behavior.

ldore added a commit to ldore/pycparser that referenced this issue Nov 8, 2022
ldore added a commit to ldore/pycparser that referenced this issue Nov 10, 2022
@eliben eliben closed this as completed in f5ca028 Nov 10, 2022
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