From 3275f9ccb93a559a34baeb52f86c192a30e914b0 Mon Sep 17 00:00:00 2001 From: Werner Henze <34543625+beinhaerter@users.noreply.github.com> Date: Sat, 12 Oct 2024 02:46:21 +0200 Subject: [PATCH] Fix gcc build problem (#1149) Closes issue #1148 by fixing problems introduced in PR #1140. Co-authored-by: Werner Henze --- include/gsl/span | 12 ++++++++---- include/gsl/util | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/gsl/span b/include/gsl/span index 0de2932..d2ef9f7 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -64,10 +64,12 @@ #endif // Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" -#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") +#endif // __has_warning("-Wunsafe-buffer-usage") +#endif // defined(__clang__) namespace gsl { @@ -852,8 +854,10 @@ as_writable_bytes(span s) noexcept #pragma GCC diagnostic pop #endif // __GNUC__ > 6 -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") #pragma clang diagnostic pop -#endif +#endif // __has_warning("-Wunsafe-buffer-usage") +#endif // defined(__clang__) #endif // GSL_SPAN_H diff --git a/include/gsl/util b/include/gsl/util index b853017..26b2f5f 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -41,10 +41,12 @@ #endif // _MSC_VER // Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" -#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") +#endif // __has_warning("-Wunsafe-buffer-usage") +#endif // defined(__clang__) #if defined(__cplusplus) && (__cplusplus >= 201703L) #define GSL_NODISCARD [[nodiscard]] @@ -160,8 +162,10 @@ constexpr auto at(std::span sp, const index i) -> decltype(sp[sp.size #endif // _MSC_VER -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") #pragma clang diagnostic pop -#endif +#endif // __has_warning("-Wunsafe-buffer-usage") +#endif // defined(__clang__) #endif // GSL_UTIL_H