diff --git a/cmake/clang_flags.cmake b/cmake/clang_flags.cmake index 5ff3db11e..ef320fadb 100644 --- a/cmake/clang_flags.cmake +++ b/cmake/clang_flags.cmake @@ -2,8 +2,6 @@ # -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 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 @@ -21,7 +19,6 @@ set(CLANG_CXXFLAGS -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-deprecated-declarations - -Wno-extra-semi-stmt -Wno-padded -Wno-covered-switch-default -Wno-c2y-extensions diff --git a/tests/abi/config/config.hpp b/tests/abi/config/config.hpp index 63681899f..9247a0240 100644 --- a/tests/abi/config/config.hpp +++ b/tests/abi/config/config.hpp @@ -28,7 +28,7 @@ std::string namespace_name(std::string ns, T* /*unused*/ = nullptr) // NOLINT(pe std::smatch m; // extract the true namespace name from the function signature - CAPTURE(ns); + CAPTURE(ns) CHECK(std::regex_search(ns, m, std::regex("nlohmann(::[a-zA-Z0-9_]+)*::basic_json"))); return m.str(); diff --git a/tests/src/unit-32bit.cpp b/tests/src/unit-32bit.cpp index aead04205..6c13883f8 100644 --- a/tests/src/unit-32bit.cpp +++ b/tests/src/unit-32bit.cpp @@ -59,10 +59,10 @@ TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test) INFO("type := ", type_str); - CAPTURE(val_min); - CAPTURE(min_in_range); - CAPTURE(val_max); - CAPTURE(max_in_range); + CAPTURE(val_min) + CAPTURE(min_in_range) + CAPTURE(val_max) + CAPTURE(max_in_range) if (min_in_range) { diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 9dde143c2..0dbb66ddb 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -239,7 +239,7 @@ TEST_CASE("controlled bad_alloc") // iterative path instead, part-way through its worklist. const auto check_deep_copy = [](bool objects) { - CAPTURE(objects); + CAPTURE(objects) next_construct_fails = false; diff --git a/tests/src/unit-binary_writer_sinks.cpp b/tests/src/unit-binary_writer_sinks.cpp index d13f5e5ac..b780dc0b5 100644 --- a/tests/src/unit-binary_writer_sinks.cpp +++ b/tests/src/unit-binary_writer_sinks.cpp @@ -89,7 +89,7 @@ TEST_CASE("binary writer output sinks") // the first iteration for (const auto& j : test_values()) { - CAPTURE(j.dump(-1, ' ', false, json::error_handler_t::replace)); + CAPTURE(j.dump(-1, ' ', false, json::error_handler_t::replace)) std::vector cbor; json::to_cbor(j, cbor); @@ -120,8 +120,8 @@ TEST_CASE("binary writer output sinks") { continue; // not a supported combination } - CAPTURE(use_size); - CAPTURE(use_type); + CAPTURE(use_size) + CAPTURE(use_type) std::vector ubjson; json::to_ubjson(j, ubjson, use_size, use_type); CHECK(json::to_ubjson(j, use_size, use_type) == ubjson); @@ -141,7 +141,7 @@ TEST_CASE("binary writer output sinks") for (const auto& j : bson_values()) { - CAPTURE(j.dump()); + CAPTURE(j.dump()) std::vector bson; json::to_bson(j, bson); CHECK(json::to_bson(j) == bson); @@ -152,7 +152,7 @@ TEST_CASE("binary writer output sinks") { for (const auto& j : test_values()) { - CAPTURE(j.dump(-1, ' ', false, json::error_handler_t::replace)); + CAPTURE(j.dump(-1, ' ', false, json::error_handler_t::replace)) const std::vector expected = json::to_cbor(j); std::vector as_char; @@ -177,7 +177,7 @@ TEST_CASE("binary_reserve_hint never over-reserves") { for (const auto& j : test_values()) { - CAPTURE(j.dump(-1, ' ', false, json::error_handler_t::replace)); + CAPTURE(j.dump(-1, ' ', false, json::error_handler_t::replace)) const std::size_t hint = nlohmann::detail::binary_reserve_hint(j); @@ -194,7 +194,7 @@ TEST_CASE("binary_reserve_hint never over-reserves") for (const auto& j : bson_values()) { - CAPTURE(j.dump()); + CAPTURE(j.dump()) CHECK(nlohmann::detail::binary_reserve_hint(j) <= json::to_bson(j).size()); } diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index a58507c15..d4601a9f4 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -146,10 +146,10 @@ TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test) INFO("type := ", type_str); - CAPTURE(val_min); - CAPTURE(min_in_range); - CAPTURE(val_max); - CAPTURE(max_in_range); + CAPTURE(val_min) + CAPTURE(min_in_range) + CAPTURE(val_max) + CAPTURE(max_in_range) if (min_in_range) { @@ -2641,7 +2641,7 @@ TEST_CASE("BJData") {"uint8", "int8", "uint16", "int16", "uint32", "int32", "uint64", "int64", "char" }) { - CAPTURE(type); + CAPTURE(type) const std::string text = std::string(R"({"_ArrayType_":")") + type + R"(","_ArraySize_":[2,3],"_ArrayData_":[1,2,3,4,5,6]})"; const auto from_text = json::to_bjdata(json::parse(text)); @@ -2949,7 +2949,7 @@ TEST_CASE("BJData") R"({"_ArrayType_":"int16","_ArraySize_":[0,2],"_ArrayData_":[]})" }) { - CAPTURE(text); + CAPTURE(text) const json j = json::parse(text); for (const bool use_size : { @@ -2983,7 +2983,7 @@ TEST_CASE("BJData") R"({"_ArrayType_":"int16","_ArraySize_":[],"_ArrayData_":null})" }) { - CAPTURE(text); + CAPTURE(text) const json j = json::parse(text); const auto out = json::to_bjdata(j); CHECK(out.at(0) == '{'); @@ -4317,7 +4317,7 @@ TEST_CASE("BJData and UBJSON can be written to a string") for (const auto& j : values) { - CAPTURE(j.dump()); + CAPTURE(j.dump()) for (const bool use_size : { false, true @@ -4332,8 +4332,8 @@ TEST_CASE("BJData and UBJSON can be written to a string") { continue; } - CAPTURE(use_size); - CAPTURE(use_type); + CAPTURE(use_size) + CAPTURE(use_type) const auto bjdata = json::to_bjdata(j, use_size, use_type); std::string bjdata_string; diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index 292ff4dc1..439516601 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -1784,7 +1784,7 @@ TEST_CASE("BSON: deeply nested values") json value = "leaf"; for (std::size_t depth = 0; depth <= 300; ++depth) { - CAPTURE(depth); + CAPTURE(depth) const json document = {{"value", value}, {"n", depth}}; CHECK(json::from_bson(json::to_bson(document)) == document); @@ -1817,7 +1817,7 @@ value = depth % 2 == 0 ? json{{"a", std::move(value)}, {"b", {1, "x"}}} : false, true }) { - CAPTURE(objects); + CAPTURE(objects) std::string text = "{\"a\":"; for (std::size_t i = 0; i < depth; ++i) { diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp index fe0fb2644..945c99230 100644 --- a/tests/src/unit-cbor.cpp +++ b/tests/src/unit-cbor.cpp @@ -2931,7 +2931,7 @@ TEST_CASE("Tagged values") 0xD5, 0xD6, 0xD7 }) { - CAPTURE(b); + CAPTURE(b) // add tag to value auto v_tagged = v; @@ -3271,7 +3271,7 @@ TEST_CASE("CBOR large strings and binaries (chunked reader)") std::size_t{4097}, std::size_t{8192}, std::size_t{100000} }) { - CAPTURE(len); + CAPTURE(len) // text string const json j_string = std::string(len, 'x'); diff --git a/tests/src/unit-class_lexer.cpp b/tests/src/unit-class_lexer.cpp index 5d52179d7..59bcac9bc 100644 --- a/tests/src/unit-class_lexer.cpp +++ b/tests/src/unit-class_lexer.cpp @@ -268,7 +268,7 @@ TEST_CASE("lexer number fast path") std::stringstream ss(doc); const json b = json::parse(ss); - CAPTURE(n); + CAPTURE(n) CHECK(a == b); CHECK(a.dump() == b.dump()); CHECK(a[0].type() == b[0].type()); @@ -306,7 +306,7 @@ TEST_CASE("lexer number fast path") for (const auto& n : numbers) { - CAPTURE(n); + CAPTURE(n) const std::string doc = "[" + n + "]"; const json a = json::parse(doc); // contiguous fast path @@ -343,7 +343,7 @@ TEST_CASE("lexer number fast path") {"-", "1.", "1e", "1e+", "1.2e", "01", "-01", "1..2", "1.2.3" }) { - CAPTURE(bad); + CAPTURE(bad) // the contiguous fast path must decline and let the byte path report const std::string doc = std::string("[") + bad + "]"; CHECK_FALSE(json::accept(doc)); @@ -411,7 +411,7 @@ TEST_CASE("lexer number fast path") // 7 + 49 + 343 + 2401 tokens CHECK(tokens.size() == 2401); - CAPTURE(mismatches); + CAPTURE(mismatches) CHECK(mismatches.empty()); } @@ -455,7 +455,7 @@ TEST_CASE("lexer number fast path") "[1 \n2]", "[\n1\n2]", "1\n2", "[01\r\n]", "[1e\n]", "[-\n]" }) { - CAPTURE(bad); + CAPTURE(bad) const std::string doc = bad; const std::string contiguous_what = contiguous_error(doc); @@ -572,7 +572,7 @@ TEST_CASE("lexer string fast path") // 13 + 169 + 2197 tokens, each at two offsets CHECK(tokens.size() == 2197); - CAPTURE(mismatches); + CAPTURE(mismatches) CHECK(mismatches.empty()); } @@ -600,7 +600,7 @@ TEST_CASE("lexer string fast path") } } } - CAPTURE(mismatches); + CAPTURE(mismatches) CHECK(mismatches.empty()); } #endif @@ -645,10 +645,10 @@ TEST_CASE("lexer string fast path") for (const auto& test_case : cases) { - CAPTURE(test_case.description); + CAPTURE(test_case.description) for (const std::size_t offset : offsets) { - CAPTURE(offset); + CAPTURE(offset) const std::string doc = "[\"" + std::string(offset, 'a') + test_case.sequence + "\"]"; CHECK(json::accept(doc) == test_case.valid); #if !defined(JSON_NOEXCEPTION) diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index 12f7a06a5..7a5fc7034 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -2441,7 +2441,7 @@ TEST_CASE("last-read diagnostics are identical across input adapters") for (const auto& s : inputs) { - CAPTURE(s); + CAPTURE(s) // reference: contiguous std::string -> seekable (lazy) path const std::string reference = parse_error_message(s); diff --git a/tests/src/unit-comparison.cpp b/tests/src/unit-comparison.cpp index 69c0103c9..c299103c2 100644 --- a/tests/src/unit-comparison.cpp +++ b/tests/src/unit-comparison.cpp @@ -838,7 +838,7 @@ TEST_CASE("equality of objects whose entries have no fixed order") for (const std::size_t depth : std::vector {0, 200}) { - CAPTURE(depth); + CAPTURE(depth) const unordered_json descending = nest(make_unordered_object(true), depth); const unordered_json ascending = nest(make_unordered_object(false), depth); @@ -889,7 +889,7 @@ TEST_CASE("containers are compared element by element") for (const std::size_t depth : std::vector {0, 200}) { - CAPTURE(depth); + CAPTURE(depth) // objects with different keys { diff --git a/tests/src/unit-hash.cpp b/tests/src/unit-hash.cpp index eb843c291..382dfcaa2 100644 --- a/tests/src/unit-hash.cpp +++ b/tests/src/unit-hash.cpp @@ -191,7 +191,7 @@ TEST_CASE("hash of deeply nested values") // every depth on either side of where the iterative path takes over for (std::size_t depth = 0; depth <= (2 * nlohmann::detail::recursion_depth_limit()) + 10; ++depth) { - CAPTURE(depth); + CAPTURE(depth) const auto arrays = nested(depth, false); const auto objects = nested(depth, true); const auto ordered = nested(depth, true); @@ -212,7 +212,7 @@ TEST_CASE("hash of deeply nested values") false, true }) { - CAPTURE(objects); + CAPTURE(objects) const auto text = nested_text(depth, objects); const auto a = json::parse(text); const auto b = json::parse(text); diff --git a/tests/src/unit-json_patch.cpp b/tests/src/unit-json_patch.cpp index 216d00c41..743d33181 100644 --- a/tests/src/unit-json_patch.cpp +++ b/tests/src/unit-json_patch.cpp @@ -1841,7 +1841,7 @@ TEST_CASE("JSON patch - every operation on ordered_json") }; for (const auto& target : targets) { - CAPTURE(target.dump()); + CAPTURE(target.dump()) CHECK(source.patch(ordered_json::diff(source, target)) == target); } } diff --git a/tests/src/unit-large_json.cpp b/tests/src/unit-large_json.cpp index 8204ed9b6..e0385dd23 100644 --- a/tests/src/unit-large_json.cpp +++ b/tests/src/unit-large_json.cpp @@ -116,7 +116,7 @@ TEST_CASE("tests on deeply nested JSONs") // are known to meet cleanly - wherever the bound is set. for (std::size_t d = 1; d <= 300; ++d) { - CAPTURE(d); + CAPTURE(d) const json array = json::parse(std::string(d, '[') + '0' + std::string(d, ']')); const json array_copy(array); // NOLINT(performance-unnecessary-copy-initialization): the copy is what is tested diff --git a/tests/src/unit-locale-cpp.cpp b/tests/src/unit-locale-cpp.cpp index 14f743a66..7029d0b8c 100644 --- a/tests/src/unit-locale-cpp.cpp +++ b/tests/src/unit-locale-cpp.cpp @@ -286,8 +286,8 @@ TEST_CASE("locale changes between lexer construction and number conversion (#519 for (const auto& transition : transitions) { - CAPTURE(transition.first); - CAPTURE(transition.second); + CAPTURE(transition.first) + CAPTURE(transition.second) if (std::setlocale(LC_NUMERIC, transition.first) == nullptr) { @@ -365,7 +365,7 @@ TEST_CASE("locale with a multi-byte decimal point") { continue; } - CAPTURE(name); + CAPTURE(name) tested = true; // too many significant digits for Clinger's fast path, and an underflow diff --git a/tests/src/unit-merge_patch.cpp b/tests/src/unit-merge_patch.cpp index b1e0c431b..1a0ac11d3 100644 --- a/tests/src/unit-merge_patch.cpp +++ b/tests/src/unit-merge_patch.cpp @@ -305,10 +305,10 @@ TEST_CASE("JSON Merge Patch on deeply nested values") // over (detail::recursion_depth_limit(), 128) for (std::size_t depth = 0; depth <= 300; ++depth) { - CAPTURE(depth); + CAPTURE(depth) for (int variant = 0; variant < 3; ++variant) { - CAPTURE(variant); + CAPTURE(variant) const json patch = json::parse(nested_objects(depth, variant)); json result = json::parse(nested_objects(depth, (variant + 1) % 3)); diff --git a/tests/src/unit-modifiers.cpp b/tests/src/unit-modifiers.cpp index c878ec15c..0aa30b178 100644 --- a/tests/src/unit-modifiers.cpp +++ b/tests/src/unit-modifiers.cpp @@ -1044,10 +1044,10 @@ TEST_CASE("update() on deeply nested values") // over (detail::recursion_depth_limit(), 128) for (std::size_t depth = 0; depth <= 300; ++depth) { - CAPTURE(depth); + CAPTURE(depth) for (int variant = 0; variant < 3; ++variant) { - CAPTURE(variant); + CAPTURE(variant) const json source = json::parse(nested_objects(depth, variant)); json result = json::parse(nested_objects(depth, (variant + 1) % 3)); json expected = result; diff --git a/tests/src/unit-precise-stream-position.cpp b/tests/src/unit-precise-stream-position.cpp index 5b6bff682..162c892f9 100644 --- a/tests/src/unit-precise-stream-position.cpp +++ b/tests/src/unit-precise-stream-position.cpp @@ -113,7 +113,7 @@ TEST_CASE("JSON_PRECISE_STREAM_POSITION") for (const auto& test : tests) { - CAPTURE(test.first); + CAPTURE(test.first) std::istringstream ss(test.first); json j; ss >> j; @@ -135,7 +135,7 @@ TEST_CASE("JSON_PRECISE_STREAM_POSITION") for (const auto& test : tests) { - CAPTURE(test.first); + CAPTURE(test.first) std::istringstream ss(test.first); json j; ss >> j; @@ -149,7 +149,7 @@ TEST_CASE("JSON_PRECISE_STREAM_POSITION") {"1", "12", "-3.5e2", " 7 " }) { - CAPTURE(s); + CAPTURE(s) std::istringstream ss(s); json j; ss >> j; diff --git a/tests/src/unit-regression3.cpp b/tests/src/unit-regression3.cpp index 1c2ebd3f0..95b2b6d4f 100644 --- a/tests/src/unit-regression3.cpp +++ b/tests/src/unit-regression3.cpp @@ -849,13 +849,13 @@ TEST_CASE("issue #5338 - truncated CBOR tagged binary subtype is rejected") for (const auto& data : truncated_tags) { - CAPTURE(data); + CAPTURE(data) for (const auto tag_handler : { json::cbor_tag_handler_t::ignore, json::cbor_tag_handler_t::store }) { - CAPTURE(tag_handler); + CAPTURE(tag_handler) const auto result = json::from_cbor(data, true, false, tag_handler); CHECK(result.is_discarded()); } diff --git a/tests/src/unit-serialization.cpp b/tests/src/unit-serialization.cpp index bfb510fd0..4b959021e 100644 --- a/tests/src/unit-serialization.cpp +++ b/tests/src/unit-serialization.cpp @@ -584,7 +584,7 @@ TEST_CASE("serialization of deeply nested values") // value are known to meet cleanly - wherever the bound is set. for (std::size_t d = 1; d <= 300; ++d) { - CAPTURE(d); + CAPTURE(d) const std::string array_text = std::string(d, '[') + '7' + std::string(d, ']'); CHECK(json::parse(array_text).dump() == array_text); @@ -604,7 +604,7 @@ TEST_CASE("serialization of deeply nested values") { for (std::size_t d = 120; d <= 140; ++d) { - CAPTURE(d); + CAPTURE(d) const json j = json::parse(std::string(d, '[') + '7' + std::string(d, ']')); @@ -629,7 +629,7 @@ TEST_CASE("serialization of deeply nested values") // so it must not gain a newline when it is reached iteratively for (std::size_t d = 125; d <= 135; ++d) { - CAPTURE(d); + CAPTURE(d) const std::string compact = std::string(d, '[') + "[]" + std::string(d, ']'); CHECK(json::parse(compact).dump() == compact); @@ -711,10 +711,10 @@ TEST_CASE("serialization of every kind of value below the bound of the descent") for (const std::size_t depth : std::vector {1, 200}) { - CAPTURE(depth); + CAPTURE(depth) for (const auto& inner : values) { - CAPTURE(inner.dump()); + CAPTURE(inner.dump()) const json j = wrap_in_arrays(inner, depth); CHECK(j.dump() == std::string(depth, '[') + inner.dump() + std::string(depth, ']')); CHECK(j.dump(2) == expected_pretty_in_arrays(inner, depth)); @@ -725,7 +725,7 @@ TEST_CASE("serialization of every kind of value below the bound of the descent") { for (std::size_t d = 120; d <= 140; ++d) { - CAPTURE(d); + CAPTURE(d) // built from the inside out: {"k": , "n": } json j = 7; diff --git a/tests/src/unit-user_defined_input.cpp b/tests/src/unit-user_defined_input.cpp index f07a8a608..0c5cb231e 100644 --- a/tests/src/unit-user_defined_input.cpp +++ b/tests/src/unit-user_defined_input.cpp @@ -350,7 +350,7 @@ TEST_CASE("std::counted_iterator reaches the contiguous fast paths") for (const auto& text : diagnostic_docs) { - CAPTURE(text); + CAPTURE(text) const std::counted_iterator it(text.data(), static_cast>(text.size())); std::string counted_message; std::string string_message; @@ -460,8 +460,8 @@ TEST_CASE("std::counted_iterator bulk scanning stops at the counted end") for (const auto& tc : cases) { - CAPTURE(tc.buffer); - CAPTURE(tc.count); + CAPTURE(tc.buffer) + CAPTURE(tc.count) const std::string buffer = tc.buffer; CHECK(via_counted(buffer, tc.count) == via_prefix(buffer, tc.count)); }