diff --git a/cmake/ci.cmake b/cmake/ci.cmake index f593c0411..f45f9b4f3 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -114,7 +114,6 @@ set(CLANG_CXXFLAGS "-std=c++11 \ # -Wno-aggregate-return The library uses aggregate returns. # -Wno-long-long The library uses the long long type to interface with system functions. # -Wno-namespaces The library uses namespaces. -# -Wno-noexcept # -Wno-padded We do not care about padding warnings. # -Wno-system-headers We do not care about warnings in system headers. # -Wno-templates The library uses templates. diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 9b770a371..400530a60 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -38,9 +38,9 @@ // disable documentation warnings on clang #if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" - #pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" #endif // allow to disable exceptions diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp index 28be047aa..3f56e4b85 100644 --- a/include/nlohmann/detail/macro_unscope.hpp +++ b/include/nlohmann/detail/macro_unscope.hpp @@ -1,8 +1,8 @@ #pragma once -// restore GCC/clang diagnostic settings +// restore clang diagnostic settings #if defined(__clang__) - #pragma GCC diagnostic pop + #pragma clang diagnostic pop #endif // clean up diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index d123bb2d5..89c0d1ca4 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2250,9 +2250,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP // disable documentation warnings on clang #if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" - #pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" #endif // allow to disable exceptions @@ -26424,9 +26424,9 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std // #include -// restore GCC/clang diagnostic settings +// restore clang diagnostic settings #if defined(__clang__) - #pragma GCC diagnostic pop + #pragma clang diagnostic pop #endif // clean up diff --git a/test/src/unit-assert_macro.cpp b/test/src/unit-assert_macro.cpp index 826638fe6..2db78e8d9 100644 --- a/test/src/unit-assert_macro.cpp +++ b/test/src/unit-assert_macro.cpp @@ -27,13 +27,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// avoid warning when assert does not abort -#if defined(__GNUC__) - #pragma GCC diagnostic ignored "-Wstrict-overflow" -#endif - #include "doctest_compatibility.h" +// avoid warning when assert does not abort +DOCTEST_GCC_SUPPRESS_WARNING_PUSH +DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") +DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +DOCTEST_CLANG_SUPPRESS_WARNING("-Wstrict-overflow") + /// global variable to record side effect of assert calls static int assert_counter; @@ -63,3 +64,6 @@ TEST_CASE("JSON_ASSERT(x)") } } #endif + +DOCTEST_GCC_SUPPRESS_WARNING_POP +DOCTEST_CLANG_SUPPRESS_WARNING_POP diff --git a/test/src/unit-disabled_exceptions.cpp b/test/src/unit-disabled_exceptions.cpp index 6baa0f622..7ab312556 100644 --- a/test/src/unit-disabled_exceptions.cpp +++ b/test/src/unit-disabled_exceptions.cpp @@ -29,6 +29,7 @@ SOFTWARE. #include "doctest_compatibility.h" +// disable -Wnoexcept as exceptions are switched off for this test suite DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index 1e86c0a41..f6489907c 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -358,10 +358,10 @@ TEST_CASE("JSON pointers") CHECK_THROWS_WITH(j_const[jp] == 1, throw_msg.c_str()); } -#if defined(_MSC_VER) -#pragma warning (push) -#pragma warning (disable : 4127) // on some machines, the check below is not constant -#endif + // on some machines, the check below is not constant + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH + DOCTEST_MSVC_SUPPRESS_WARNING(4127) + if (sizeof(typename json::size_type) < sizeof(unsigned long long)) { auto size_type_max_uul = static_cast((std::numeric_limits::max)()); @@ -375,9 +375,7 @@ TEST_CASE("JSON pointers") CHECK_THROWS_WITH(j_const[jp] == 1, throw_msg.c_str()); } -#if defined(_MSC_VER) -#pragma warning (pop) -#endif + DOCTEST_MSVC_SUPPRESS_WARNING_POP CHECK_THROWS_AS(j.at("/one"_json_pointer) = 1, json::parse_error&); CHECK_THROWS_WITH(j.at("/one"_json_pointer) = 1, diff --git a/test/src/unit-noexcept.cpp b/test/src/unit-noexcept.cpp index 61dc2fa8d..d8f044e27 100644 --- a/test/src/unit-noexcept.cpp +++ b/test/src/unit-noexcept.cpp @@ -29,6 +29,7 @@ SOFTWARE. #include "doctest_compatibility.h" +// disable -Wnoexcept due to struct pod_bis DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 7da9c3bf5..df06dca8a 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -42,10 +42,9 @@ using nlohmann::json; #include #include -#if defined(_MSC_VER) - #pragma warning (push) - #pragma warning (disable : 4189) // local variable is initialized but not referenced -#endif +// local variable is initialized but not referenced +DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +DOCTEST_MSVC_SUPPRESS_WARNING(4189) TEST_CASE("README" * doctest::skip()) { @@ -321,6 +320,4 @@ TEST_CASE("README" * doctest::skip()) } } -#if defined(_MSC_VER) - #pragma warning (pop) -#endif +DOCTEST_MSVC_SUPPRESS_WARNING_POP diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 008257bf6..939a72bc3 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -29,6 +29,7 @@ SOFTWARE. #include "doctest_compatibility.h" +// disable -Wnoexcept due to class Evil DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept")