summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSaullo Carvalho Castelo Branco <saullocarvalho@gmail.com>2019-06-01 09:06:48 -0300
committerEli Bendersky <eliben@users.noreply.github.com>2019-06-01 05:06:48 -0700
commitdd6b6f1d4eb149b32934e02bd1e9a4af6575ce06 (patch)
treee2bdacb75168d2297d138542a637f7ca0d7de567 /tests
parentfd6acec6633c12375772917b09035098aba300ab (diff)
downloadpycparser-dd6b6f1d4eb149b32934e02bd1e9a4af6575ce06.tar.gz
Fix issue #314: Failed parsing unnamed function parameters with array dim qualifiers (#327)
Fixes #314
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_c_parser.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
index 6cd183d..ad9a218 100755
--- a/tests/test_c_parser.py
+++ b/tests/test_c_parser.py
@@ -422,6 +422,7 @@ class TestCParser_fundamentals(TestCParser_base):
['TypeDecl', ['IdentifierType', ['int']]]]]])
def test_func_decls_with_array_dim_qualifiers(self):
+ # named function parameter
self.assertEqual(self.get_decl('int zz(int p[static 10]);'),
['Decl', 'zz',
['FuncDecl',
@@ -452,6 +453,30 @@ class TestCParser_fundamentals(TestCParser_base):
['TypeDecl', ['IdentifierType', ['int']]]]]]],
['TypeDecl', ['IdentifierType', ['int']]]]])
+ # unnamed function parameter
+ self.assertEqual(self.get_decl('int zz(int [const 10]);'),
+ ['Decl', 'zz',
+ ['FuncDecl',
+ [['Typename', ['ArrayDecl', '10', ['const'],
+ ['TypeDecl', ['IdentifierType', ['int']]]]]],
+ ['TypeDecl', ['IdentifierType', ['int']]]]])
+
+ self.assertEqual(self.get_decl('int zz(int [restrict][5]);'),
+ ['Decl', 'zz',
+ ['FuncDecl',
+ [['Typename', ['ArrayDecl', '', ['restrict'],
+ ['ArrayDecl', '5', [],
+ ['TypeDecl', ['IdentifierType', ['int']]]]]]],
+ ['TypeDecl', ['IdentifierType', ['int']]]]])
+
+ self.assertEqual(self.get_decl('int zz(int [const restrict volatile 10][5]);'),
+ ['Decl', 'zz',
+ ['FuncDecl',
+ [['Typename', ['ArrayDecl', '10', ['const', 'restrict', 'volatile'],
+ ['ArrayDecl', '5', [],
+ ['TypeDecl', ['IdentifierType', ['int']]]]]]],
+ ['TypeDecl', ['IdentifierType', ['int']]]]])
+
def test_qualifiers_storage_specifiers(self):
def assert_qs(txt, index, quals, storage):
d = self.parse(txt).ext[index]