summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-12-09 10:34:29 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2018-12-09 10:41:26 +0100
commit5720c77acde1b2348f3c3d08e3a27cf624be1323 (patch)
treeaed9e8b2af27d70234edb5c2fb26ab6feb1760ca
parentee5a93788618d85e4be1b4c96cb8ba3daf0b6173 (diff)
downloadgobject-introspection-5720c77acde1b2348f3c3d08e3a27cf624be1323.tar.gz
sourcescanner: Allow empty declarations. Fixes #216
As far as I see these are not valid C and only allowed in C++11. But they do occur in the wild (mingw headers) so let's try to handle them.
-rw-r--r--giscanner/scannerparser.y4
-rw-r--r--tests/scanner/test_sourcescanner.py6
2 files changed, 10 insertions, 0 deletions
diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y
index 72c17ec3..299910da 100644
--- a/giscanner/scannerparser.y
+++ b/giscanner/scannerparser.y
@@ -791,6 +791,9 @@ declaration
}
;
+empty_declaration
+ : ';'
+
declaration_specifiers
: storage_class_specifier declaration_specifiers
{
@@ -1459,6 +1462,7 @@ translation_unit
external_declaration
: function_definition
| declaration
+ | empty_declaration
| macro
;
diff --git a/tests/scanner/test_sourcescanner.py b/tests/scanner/test_sourcescanner.py
index 2f383af7..c731049b 100644
--- a/tests/scanner/test_sourcescanner.py
+++ b/tests/scanner/test_sourcescanner.py
@@ -72,6 +72,12 @@ void foo(int bar) {
self.assertEqual(len(list(scanner.get_comments())), 1)
self.assertFalse(scanner.get_errors())
+ def test_empty_decl(self):
+ # https://gitlab.gnome.org/GNOME/gobject-introspection/issues/216
+ scanner = self._parse_files(";int foo;")
+ self.assertEqual(len(list(scanner.get_symbols())), 1)
+ self.assertFalse(scanner.get_errors())
+
if __name__ == '__main__':
unittest.main()