From: Jérémie Galarneau Date: Mon, 9 Sep 2024 15:53:28 +0000 (-0400) Subject: Use compiler-agnostic defines to silence warning X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fdf647bb757759bc13da7cc38260f19984d04801;p=lttng-tools.git Use compiler-agnostic defines to silence warning 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 Change-Id: I543987a861d2322aa2ef3b7d631f280d2ac999bf --- diff --git a/src/common/macros.hpp b/src/common/macros.hpp index f1d039a1f..31190f2ba 100644 --- a/src/common/macros.hpp +++ b/src/common/macros.hpp @@ -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. */ diff --git a/src/common/reference.hpp b/src/common/reference.hpp index 15dac55b9..f8ba33fed 100644 --- a/src/common/reference.hpp +++ b/src/common/reference.hpp @@ -8,6 +8,8 @@ #ifndef LTTNG_REFERENCE_H #define LTTNG_REFERENCE_H +#include + #include #include @@ -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::value, "CustomDeleter must define a 'deleter' callable class."); const typename CustomDeleter::deleter del; -#pragma clang diagnostic pop + DIAGNOSTIC_POP del(_value); release();