Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_no_added_attr():
src = """
char* foo() {
return "";
}
int main() {
return 0;
}
"""
import pycparserext.ext_c_parser as ext_c_parser
import pycparserext.ext_c_generator as ext_c_generator
parser = ext_c_parser.GnuCParser()
ast = parser.parse(src)
gen = ext_c_generator.GnuCGenerator()
print(gen.visit(ast))
assert "attr" not in gen.visit(ast)
src = """
struct foo {
const char *bar;
const char *baz;
};
int main () {
return 0;
}
"""
import pycparserext.ext_c_parser as ext_c_parser
import pycparserext.ext_c_generator as ext_c_generator
parser = ext_c_parser.GnuCParser()
ast = parser.parse(src)
gen = ext_c_generator.GnuCGenerator()
print(gen.visit(ast))