diff options
author | Eli Bendersky <eliben@gmail.com> | 2016-10-11 20:44:32 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2016-10-11 20:44:32 -0700 |
commit | dbf9be20e7cf252d3d8f5e98775a8e4dc23613a3 (patch) | |
tree | a8c5faa14e968574e03db18ddb5fa3b88ef7d360 | |
parent | b77d6c0d90d3f7c6dcc07efee15670492683f144 (diff) | |
download | pycparser-dbf9be20e7cf252d3d8f5e98775a8e4dc23613a3.tar.gz |
Issue #116: Fix coord assignment to compound statements
-rw-r--r-- | pycparser/c_parser.py | 2 | ||||
-rwxr-xr-x | tests/test_c_parser.py | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py index 71efa72..dc13962 100644 --- a/pycparser/c_parser.py +++ b/pycparser/c_parser.py @@ -1698,11 +1698,13 @@ class CParser(PLYParser): """ brace_open : LBRACE """ p[0] = p[1] + p.set_lineno(0, p.lineno(1)) def p_brace_close(self, p): """ brace_close : RBRACE """ p[0] = p[1] + p.set_lineno(0, p.lineno(1)) def p_empty(self, p): 'empty : ' diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py index 761d902..e32c49d 100755 --- a/tests/test_c_parser.py +++ b/tests/test_c_parser.py @@ -496,6 +496,15 @@ class TestCParser_fundamentals(TestCParser_base): s4 = compound.block_items[3].init self.assertTrue(isinstance(s4.args.exprs[1], ArrayRef)) + def test_compound_statement(self): + e = """ + void foo() { + } + """ + compound = self.parse(e).ext[0].body + self.assertTrue(isinstance(compound, Compound)) + self.assert_coord(compound, 2, '') + # The C99 compound literal feature # def test_compound_literals(self): |