diff --git a/cmake/clang_flags.cmake b/cmake/clang_flags.cmake index 0619545ec..5ff3db11e 100644 --- a/cmake/clang_flags.cmake +++ b/cmake/clang_flags.cmake @@ -2,7 +2,8 @@ # -Wno-c++98-compat The library targets C++11. # -Wno-c++98-compat-pedantic The library targets C++11. # -Wno-deprecated-declarations The library contains annotations for deprecated functions. -# -Wno-extra-semi-stmt The library uses assert which triggers this warning. +# -Wno-extra-semi-stmt Vendored Doctest's CAPTURE() macro expands to a +# statement followed by a semicolon at every call site. # -Wno-padded We do not care about padding warnings. # -Wno-covered-switch-default All switches list all cases and a default case. # -Wno-c2y-extensions Clang 22.1 diagnoses __COUNTER__ as a C2y extension, also in diff --git a/tests/src/unit-assert_macro.cpp b/tests/src/unit-assert_macro.cpp index adedfc934..ab15b8e5f 100644 --- a/tests/src/unit-assert_macro.cpp +++ b/tests/src/unit-assert_macro.cpp @@ -18,7 +18,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING("-Wstrict-overflow") static int assert_counter; /// set failure variable to true instead of calling assert(x) -#define JSON_ASSERT(x) {if (!(x)) ++assert_counter; } +#define JSON_ASSERT(x) do { if (!(x)) { ++assert_counter; } } while (false) #include using nlohmann::json;