Merge pull request #59 from akiradeveloper/feature/fix-comma-op-assign
fix: Comma operator in Assignment
diff --git a/pycparser/c_generator.py b/pycparser/c_generator.py
index 3880ce4..a76638d 100644
--- a/pycparser/c_generator.py
+++ b/pycparser/c_generator.py
@@ -379,7 +379,7 @@
""" Visits 'n' and returns its string representation, parenthesized
if the condition function applied to the node returns True.
"""
- s = self.visit(n)
+ s = self._visit_expr(n)
if condition(n):
return '(' + s + ')'
else:
diff --git a/tests/test_c_generator.py b/tests/test_c_generator.py
index a21a0b1..7210294 100644
--- a/tests/test_c_generator.py
+++ b/tests/test_c_generator.py
@@ -21,6 +21,7 @@
return False
ast1 = ast1[1]
ast2 = ast2[1]
+ return compare_asts(ast1, ast2)
for attr in ast1.attr_names:
if getattr(ast1, attr) != getattr(ast2, attr):
return False
@@ -208,5 +209,12 @@
}
''')
+ def test_comma_op_assignment(self):
+ self._assert_ctoc_correct(r'''
+ void f() {
+ i = (a, b, c);
+ }
+ ''')
+
if __name__ == "__main__":
unittest.main()