Use compiler-agnostic defines to silence warning
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 9 Sep 2024 15:53:28 +0000 (11:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 9 Sep 2024 15:55:01 +0000 (11:55 -0400)
g++ emits warnings that it can't recognize the clang-specific diagnostic
pragmas. They are replaced by the internal compiler-specific macros so
that nothing is emitted when g++ is used.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I543987a861d2322aa2ef3b7d631f280d2ac999bf

src/common/macros.hpp
src/common/reference.hpp

index f1d039a1f4643fa3f3fb30771d5b375e934212a1..31190f2ba7acc317fb92932fc27c6c56efbb3c94 100644 (file)
@@ -270,6 +270,8 @@ void *memmove(DestinationType *d, const SourceType *s, size_t n) = delete;
 #define DIAGNOSTIC_IGNORE_LOGICAL_OP
 #define DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES
 #define DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
+#define DIAGNOSTIC_IGNORE_INJECTED_CLASS_NAME \
+       _Pragma("GCC diagnostic ignored \"-Winjected-class-name\"")
 _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
 #else
 /* GCC */
@@ -285,6 +287,8 @@ _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
 #define DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES
 #endif /* __GNUG__ && __GNUC__ >= 7 */
 #define DIAGNOSTIC_IGNORE_INVALID_OFFSETOF _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
+
+#define DIAGNOSTIC_IGNORE_INJECTED_CLASS_NAME
 #endif
 
 /* Used to make specific C++ functions to C code. */
index 15dac55b9aa381026779cf5e1303f1f964a5c6f5..f8ba33fed325bff435ab7800c7e30f53341b80ab 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef LTTNG_REFERENCE_H
 #define LTTNG_REFERENCE_H
 
+#include <common/macros.hpp>
+
 #include <algorithm>
 #include <utility>
 
@@ -76,12 +78,12 @@ private:
                        return;
                }
 
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Winjected-class-name"
+               DIAGNOSTIC_PUSH
+               DIAGNOSTIC_IGNORE_INJECTED_CLASS_NAME
                static_assert(std::is_class<typename CustomDeleter::deleter>::value,
                              "CustomDeleter must define a 'deleter' callable class.");
                const typename CustomDeleter::deleter del;
-#pragma clang diagnostic pop
+               DIAGNOSTIC_POP
 
                del(_value);
                release();
This page took 0.026366 seconds and 4 git commands to generate.