summaryrefslogtreecommitdiff
path: root/tests/test_c_parser.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2016-03-19 05:21:59 -0700
committerEli Bendersky <eliben@gmail.com>2016-03-19 05:21:59 -0700
commit95e3b761d93ce95f42edccd15b1b2e81f75193a2 (patch)
treecce44867524e61dfbb7425a1ac2358274fc7798e /tests/test_c_parser.py
parentad996555659a8b8908358f45ad326d0a26eddcfa (diff)
downloadpycparser-95e3b761d93ce95f42edccd15b1b2e81f75193a2.tar.gz
Fix parsing of extra semi-colons inside structure declarations.
Fixes #117
Diffstat (limited to 'tests/test_c_parser.py')
-rwxr-xr-xtests/test_c_parser.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
index 521f77f..277c750 100755
--- a/tests/test_c_parser.py
+++ b/tests/test_c_parser.py
@@ -763,6 +763,37 @@ class TestCParser_fundamentals(TestCParser_base):
['Decl', 'heads',
['PtrDecl', ['PtrDecl', ['TypeDecl', ['IdentifierType', ['Node']]]]]]]]]])
+ def test_struct_with_extra_semis_inside(self):
+ s1 = """
+ struct {
+ int a;;
+ } foo;
+ """
+ s1_ast = self.parse(s1)
+ self.assertEqual(expand_decl(s1_ast.ext[0]),
+ ['Decl', 'foo',
+ ['TypeDecl', ['Struct', None,
+ [['Decl', 'a',
+ ['TypeDecl', ['IdentifierType', ['int']]]]]]]])
+
+ s2 = """
+ struct {
+ int a;;;;
+ float b, c;
+ ;;
+ char d;
+ } foo;
+ """
+ s2_ast = self.parse(s2)
+ self.assertEqual(expand_decl(s2_ast.ext[0]),
+ ['Decl', 'foo',
+ ['TypeDecl', ['Struct', None,
+ [['Decl', 'a', ['TypeDecl', ['IdentifierType', ['int']]]],
+ ['Decl', 'b', ['TypeDecl', ['IdentifierType', ['float']]]],
+ ['Decl', 'c', ['TypeDecl', ['IdentifierType', ['float']]]],
+ ['Decl', 'd',
+ ['TypeDecl', ['IdentifierType', ['char']]]]]]]])
+
def test_anonymous_struct_union(self):
s1 = """
union