summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-12-08 22:26:30 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2018-12-08 22:26:30 +0000
commit3f118aa426c1bcd47883a7525735ad8023842968 (patch)
tree5ce9974c16bb3bc956ff949cd1392b0da24a9096
parentb18e5fc4c290642e95a2ea296c1b843facf47067 (diff)
parent85e29abff63c00021674f33d5cae84873cd06c95 (diff)
downloadgobject-introspection-3f118aa426c1bcd47883a7525735ad8023842968.tar.gz
Merge branch 'pragma' into 'master'
Ignore __pragma keyword used by MSVC See merge request GNOME/gobject-introspection!87
-rw-r--r--giscanner/scannerlexer.l1
-rw-r--r--tests/scanner/test_sourcescanner.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index c2fb7234..42e79d42 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -173,6 +173,7 @@ stringtext ([^\\\"])|(\\.)
"_Nullable" { /* Ignore */ }
"_Null_unspecified" { /* Ignore */ }
"_Noreturn" { /* Ignore */ }
+"__pragma" { if (!parse_ignored_macro()) REJECT; }
"__restrict" { return RESTRICT; }
"__restrict__" { return RESTRICT; }
"thread_local" { return THREAD_LOCAL; }
diff --git a/tests/scanner/test_sourcescanner.py b/tests/scanner/test_sourcescanner.py
index ecd312e3..2f383af7 100644
--- a/tests/scanner/test_sourcescanner.py
+++ b/tests/scanner/test_sourcescanner.py
@@ -46,6 +46,19 @@ void foo() {
self.assertEqual(len(errors), 1)
self.assertTrue("syntax error" in errors[0])
+ def test_ignore_pragma(self):
+ """Pragma directive and __pragma keyword are ignored"""
+ scanner = self._parse_files("""
+#pragma warning(push)
+void test(void) {
+ __pragma(warning(push))
+ __pragma(warning(disable:6246))
+ __pragma(warning(pop))
+}
+#pragma warning(pop)
+""")
+ self.assertFalse(scanner.get_errors())
+
def test_ignore_typeof(self):
# https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/71
scanner = self._parse_files("""