summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2018-12-08 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2018-12-08 23:14:02 +0100
commit85e29abff63c00021674f33d5cae84873cd06c95 (patch)
tree5ce9974c16bb3bc956ff949cd1392b0da24a9096
parentb18e5fc4c290642e95a2ea296c1b843facf47067 (diff)
downloadgobject-introspection-85e29abff63c00021674f33d5cae84873cd06c95.tar.gz
Ignore __pragma keyword used by MSVC
-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("""