[gobject-introspection: 1/2] Ignore __pragma keyword used by MSVC
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection: 1/2] Ignore __pragma keyword used by MSVC
- Date: Sat, 8 Dec 2018 22:26:44 +0000 (UTC)
commit 85e29abff63c00021674f33d5cae84873cd06c95
Author: Tomasz Miąsko <tomasz miasko gmail com>
Date: Sat Dec 8 00:00:00 2018 +0000
Ignore __pragma keyword used by MSVC
giscanner/scannerlexer.l | 1 +
tests/scanner/test_sourcescanner.py | 13 +++++++++++++
2 files changed, 14 insertions(+)
---
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("""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]