diff options
author | Eli Bendersky <eliben@gmail.com> | 2016-03-19 05:21:59 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2016-03-19 05:21:59 -0700 |
commit | 95e3b761d93ce95f42edccd15b1b2e81f75193a2 (patch) | |
tree | cce44867524e61dfbb7425a1ac2358274fc7798e /tests | |
parent | ad996555659a8b8908358f45ad326d0a26eddcfa (diff) | |
download | pycparser-95e3b761d93ce95f42edccd15b1b2e81f75193a2.tar.gz |
Fix parsing of extra semi-colons inside structure declarations.
Fixes #117
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_c_parser.py | 31 |
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 |