diff options
-rw-r--r-- | pycparser/c_generator.py | 2 | ||||
-rw-r--r-- | tests/test_c_generator.py | 8 |
2 files changed, 9 insertions, 1 deletions
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 @@ class CGenerator(object): """ 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 @@ def compare_asts(ast1, ast2): 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 @@ class TestCtoC(unittest.TestCase): } ''') + def test_comma_op_assignment(self): + self._assert_ctoc_correct(r''' + void f() { + i = (a, b, c); + } + ''') + if __name__ == "__main__": unittest.main() |