From 4b719be9692124cd7b9325732859aaddbb5df9bc Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 3 Apr 2025 08:03:08 -0600 Subject: [PATCH] :bug: Fix pragma usage for turning of C++26 extensions warning Problem: - Using `STDX_PRAGMA` outside the `STATIC_ASSERT` macro doesn't apply to its contents. Solution: - Use `STDX_PRAGMA` inside the macro. --- include/stdx/static_assert.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/stdx/static_assert.hpp b/include/stdx/static_assert.hpp index 7a67eb8..53bb34e 100644 --- a/include/stdx/static_assert.hpp +++ b/include/stdx/static_assert.hpp @@ -39,16 +39,16 @@ template constexpr auto static_format() { } // namespace v1 } // namespace stdx -STDX_PRAGMA(diagnostic push) -#ifdef __clang__ -STDX_PRAGMA(diagnostic ignored "-Wunknown-warning-option") -STDX_PRAGMA(diagnostic ignored "-Wc++26-extensions") -#endif #if __cpp_static_assert >= 202306L +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define STATIC_ASSERT(cond, ...) \ []() -> bool { \ + STDX_PRAGMA(diagnostic push) \ + STDX_PRAGMA(diagnostic ignored "-Wunknown-warning-option") \ + STDX_PRAGMA(diagnostic ignored "-Wc++26-extensions") \ static_assert( \ B, std::string_view{stdx::detail::static_format<__VA_ARGS__>()}); \ + STDX_PRAGMA(diagnostic pop) \ return B; \ }.template operator()() #else @@ -58,8 +58,6 @@ STDX_PRAGMA(diagnostic ignored "-Wc++26-extensions") stdx::ct_check.template emit()>(); \ return B; \ }.template operator()() - #endif -STDX_PRAGMA(diagnostic pop) #endif