blob: 2f7542c62c86fa9ef389883a622913481e67dae1 [file] [log] [blame]
From aa4fd1f57794964640005900c2b47af1a0940b7b Mon Sep 17 00:00:00 2001
From: Werner Henze <w.henze@avm.de>
Date: Fri, 1 Mar 2024 15:53:50 +0100
Subject: [PATCH] Fix gcc build problem
Closes issue #1148 by fixing problems introduced in PR #1140.
Upstream-Status: Submitted [https://github.com/microsoft/GSL/pull/1149]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
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
@@ -59,10 +59,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
{
@@ -824,8 +826,10 @@ as_writable_bytes(span<ElementType, Extent> 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
@@ -40,10 +40,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]]
@@ -163,8 +165,10 @@ constexpr auto at(std::span<T, extent> 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
--
2.30.2