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

Generating incorrect code for char* in function declaration #20

Closed
jfoote opened this issue Sep 25, 2016 · 0 comments
Closed

Generating incorrect code for char* in function declaration #20

jfoote opened this issue Sep 25, 2016 · 0 comments

Comments

@jfoote
Copy link

jfoote commented Sep 25, 2016

Hello again,

The patch for #19 worked -- thank you for the quick fix!

pycparserext seems to be appending an empty __attribute__ to declarations of functions that return pointer types (*). This is similar to #19 but slightly different. This bug can be reproduced by this POC with pycparserext installed from the master branch:

#!/usr/bin/env python

from pycparserext import ext_c_parser, ext_c_generator

src = '''
char* foo() {
    return "";
} 

int main() {
    return 0;
}
'''

parser = ext_c_parser.GnuCParser()
ast = parser.parse(src)
gen = ext_c_generator.GnuCGenerator()
print gen.visit(ast)

Running this program results in the following output:

char *foo() __attribute__(())
{
  return "";
}

int main()
{
  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant