From 976f4a891f0d8791950bb35fc1e2b07dc5509fa9 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Thu, 22 Nov 2018 10:25:31 +0100
Subject: [PATCH] Define macros to correctly remove unknown attributes warnings

- PRAGMA_DIAGNOSTIC_IGNORED_WATTRIBUTES
- PRAGMA_DIAGNOSTIC_POP
---
 src/utils/PastisAssert.hpp |  6 ++++--
 src/utils/PastisMacros.hpp | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/utils/PastisAssert.hpp b/src/utils/PastisAssert.hpp
index d260ce25f..6bcab320d 100644
--- a/src/utils/PastisAssert.hpp
+++ b/src/utils/PastisAssert.hpp
@@ -1,6 +1,8 @@
 #ifndef PASTIS_ASSERT_HPP
 #define PASTIS_ASSERT_HPP
 
+#include <PastisMacros.hpp>
+
 #include <rang.hpp>
 #include <iostream>
 #include <string>
@@ -45,14 +47,14 @@ class AssertError
   ~AssertError() = default;
 };
 
-#pragma GCC diagnostic ignored "-Wattributes"
+PRAGMA_DIAGNOSTIC_IGNORED_WATTRIBUTES
 inline bool
 __attribute__((analyzer_noreturn))
 _pastis_assert(const bool& assert)
 {
   return assert;
 }
-#pragma GCC diagnostic pop
+PRAGMA_DIAGNOSTIC_POP
 
 #ifdef NDEBUG
 
diff --git a/src/utils/PastisMacros.hpp b/src/utils/PastisMacros.hpp
index 59d2a5795..27f686688 100644
--- a/src/utils/PastisMacros.hpp
+++ b/src/utils/PastisMacros.hpp
@@ -10,4 +10,20 @@
 
 #define PASTIS_LAMBDA KOKKOS_LAMBDA
 
+// Sets macro to ignore unknown pragma
+
+#if !defined(__clang__) and defined(__GNUC__)
+
+#define PRAGMA_DIAGNOSTIC_IGNORED_WATTRIBUTES           \
+  _Pragma ("GCC diagnostic ignored \"-Wattributes\"")
+#define PRAGMA_DIAGNOSTIC_POP                   \
+  _Pragma ("GCC diagnostic pop")
+
+#else // !defined(__clang__) and defined(__GNUC__)
+
+#define PRAGMA_DIAGNOSTIC_IGNORED_WATTRIBUTES
+#define PRAGMA_DIAGNOSTIC_POP
+
+#endif
+
 #endif // PASTIS_MACROS_HPP
-- 
GitLab