Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pycparser/c_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def _generate_stmt(self, n, add_indent=False):
c_ast.Decl, c_ast.Assignment, c_ast.Cast, c_ast.UnaryOp,
c_ast.BinaryOp, c_ast.TernaryOp, c_ast.FuncCall, c_ast.ArrayRef,
c_ast.StructRef, c_ast.Constant, c_ast.ID, c_ast.Typedef,
c_ast.ExprList):
c_ast.ExprList, c_ast.CompoundLiteral):
# These can also appear in an expression context so no semicolon
# is added to them automatically
#
Expand Down
15 changes: 15 additions & 0 deletions tests/test_c_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,20 @@ def test_reduce_parentheses_binaryops(self):
msg="{!r} did not have minimum number of parenthesis, should be like {!r}.".format(
src2, src))

def test_issue573(self):
self._assert_ctoc_correct('''
struct a {
int m;
};

struct a test() {
int x = 1;
return ({
(struct a){x};
});
}
''')


class TestCasttoC(unittest.TestCase):
def _find_file(self, name):
Expand Down Expand Up @@ -551,5 +565,6 @@ def test_nested_else_if_line_breaks(self):
self.assertEqual(generator.visit(test_ast4),
'if ()\n{\n}\nelse\n if ()\n{\n}\nelse\n if ()\n{\n}\n')


if __name__ == "__main__":
unittest.main()
Loading