diff options
author | Eli Bendersky <eliben@users.noreply.github.com> | 2014-10-05 07:06:37 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@users.noreply.github.com> | 2014-10-05 07:06:37 -0700 |
commit | c926670643ebb5f88a2bf56579fc9934c82be6d2 (patch) | |
tree | 21aa1b0c28bed9dc27e9e1a947016623f6575045 | |
parent | f888684f6aa45f7e166b3b5a2779e8bb64acbac3 (diff) | |
parent | c53b0f336e3bd5ef2e36fb5f94a9928cdd1fd515 (diff) | |
download | pycparser-c926670643ebb5f88a2bf56579fc9934c82be6d2.tar.gz |
Merge pull request #59 from akiradeveloper/feature/fix-comma-op-assign
fix: Comma operator in Assignment
-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() |