From 3b88b3c763106d70280de4c97e3c4336b138be97 Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Mon, 16 Jan 2023 15:41:41 +0100 Subject: [PATCH] iox-#1726 Remove 'gnu::warn_unused' which doesn't do the expected Signed-off-by: Simon Hoinkis --- .../linux/include/iceoryx_platform/attributes.hpp | 14 +++++++------- .../mac/include/iceoryx_platform/attributes.hpp | 2 +- .../qnx/include/iceoryx_platform/attributes.hpp | 15 +++++++++------ .../unix/include/iceoryx_platform/attributes.hpp | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/iceoryx_platform/linux/include/iceoryx_platform/attributes.hpp b/iceoryx_platform/linux/include/iceoryx_platform/attributes.hpp index 7988248cf8a..9c1d09821b6 100644 --- a/iceoryx_platform/linux/include/iceoryx_platform/attributes.hpp +++ b/iceoryx_platform/linux/include/iceoryx_platform/attributes.hpp @@ -18,14 +18,11 @@ #define IOX_HOOFS_LINUX_PLATFORM_ATTRIBUTES_HPP /// @brief IOX_NO_DISCARD adds the [[nodiscard]] keyword if it is available for the current compiler. -/// @note -// [[nodiscard]], [[gnu::warn_unused]] supported since gcc 4.8 (https://gcc.gnu.org/projects/cxx-status.html) -/// [[nodiscard]], [[gnu::warn_unused]] supported since clang 3.9 (https://clang.llvm.org/cxx_status.html) #if __cplusplus >= 201703L -#define IOX_NO_DISCARD [[nodiscard, gnu::warn_unused]] +#define IOX_NO_DISCARD [[nodiscard]] #else -#define IOX_NO_DISCARD [[gnu::warn_unused]] +#define IOX_NO_DISCARD #endif /// @brief IOX_FALLTHROUGH adds the [[fallthrough]] keyword when it is available for the current compiler. @@ -44,8 +41,11 @@ #endif /// @brief IOX_MAYBE_UNUSED adds the [[gnu::unused]] attribute when it is available for the current -/// compiler. -/// @note +/// compiler or uses C++17's 'maybe_unused'. +#if __cplusplus >= 201703L +#define IOX_MAYBE_UNUSED [[maybe_unused]] +#else #define IOX_MAYBE_UNUSED [[gnu::unused]] +#endif #endif // IOX_HOOFS_LINUX_PLATFORM_ATTRIBUTES_HPP diff --git a/iceoryx_platform/mac/include/iceoryx_platform/attributes.hpp b/iceoryx_platform/mac/include/iceoryx_platform/attributes.hpp index 992bbaaa00d..056b9cad7d3 100644 --- a/iceoryx_platform/mac/include/iceoryx_platform/attributes.hpp +++ b/iceoryx_platform/mac/include/iceoryx_platform/attributes.hpp @@ -17,7 +17,7 @@ #ifndef IOX_HOOFS_MAC_PLATFORM_ATTRIBUTES_HPP #define IOX_HOOFS_MAC_PLATFORM_ATTRIBUTES_HPP -#define IOX_NO_DISCARD [[nodiscard, gnu::warn_unused]] +#define IOX_NO_DISCARD [[nodiscard]] #define IOX_FALLTHROUGH [[fallthrough]] diff --git a/iceoryx_platform/qnx/include/iceoryx_platform/attributes.hpp b/iceoryx_platform/qnx/include/iceoryx_platform/attributes.hpp index f5431e7e13f..6129d10ccf8 100644 --- a/iceoryx_platform/qnx/include/iceoryx_platform/attributes.hpp +++ b/iceoryx_platform/qnx/include/iceoryx_platform/attributes.hpp @@ -17,13 +17,12 @@ #ifndef IOX_HOOFS_QNX_PLATFORM_ATTRIBUTES_HPP #define IOX_HOOFS_QNX_PLATFORM_ATTRIBUTES_HPP -/// @todo iox-#638 +/// @todo iox-#638 Are any of the below flags available with C++14 on QCC? +#if __cplusplus >= 201703L +#define IOX_NO_DISCARD [[nodiscard]] +#else #define IOX_NO_DISCARD - -/// @brief IOX_FALLTHROUGH adds the [[fallthrough]] keyword when it is available for the current compiler. -/// @note -// [[fallthrough]] supported since gcc 7 (https://gcc.gnu.org/projects/cxx-status.html) -/// [[fallthrough]] supported since clang 3.9 (https://clang.llvm.org/cxx_status.html) +#endif #if __cplusplus >= 201703L #define IOX_FALLTHROUGH [[fallthrough]] @@ -31,6 +30,10 @@ #define IOX_FALLTHROUGH #endif +#if __cplusplus >= 201703L +#define IOX_MAYBE_UNUSED [[maybe_unused]] +#else #define IOX_MAYBE_UNUSED [[gnu::unused]] +#endif #endif // IOX_HOOFS_QNX_PLATFORM_ATTRIBUTES_HPP diff --git a/iceoryx_platform/unix/include/iceoryx_platform/attributes.hpp b/iceoryx_platform/unix/include/iceoryx_platform/attributes.hpp index 674a77c7b4c..1e011f64420 100644 --- a/iceoryx_platform/unix/include/iceoryx_platform/attributes.hpp +++ b/iceoryx_platform/unix/include/iceoryx_platform/attributes.hpp @@ -17,7 +17,7 @@ #ifndef IOX_HOOFS_UNIX_PLATFORM_ATTRIBUTES_HPP #define IOX_HOOFS_UNIX_PLATFORM_ATTRIBUTES_HPP -#define IOX_NO_DISCARD [[nodiscard, gnu::warn_unused]] +#define IOX_NO_DISCARD [[nodiscard]] #define IOX_FALLTHROUGH [[fallthrough]]