diff --git a/.appveyor.yml b/.appveyor.yml index c447a9ca..cdd1242f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,7 +19,7 @@ build_script: - set - mkdir build - cd build - - cmake -DSIMDJSON_BUILD_STATIC=%SIMDJSON_BUILD_STATIC% -DSIMDJSON_ENABLE_THREADS=%SIMDJSON_ENABLE_THREADS% -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_GENERATOR_PLATFORM=x64 -DSIMDJSON_GOOGLE_BENCHMARKS=OFF .. + - cmake -DSIMDJSON_BUILD_STATIC=%SIMDJSON_BUILD_STATIC% -DSIMDJSON_ENABLE_THREADS=%SIMDJSON_ENABLE_THREADS% -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_GENERATOR_PLATFORM=x64 .. - cmake -LH .. - cmake --build . --config %Configuration% --verbose diff --git a/CMakeLists.txt b/CMakeLists.txt index a5606f2c..ab032bc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,10 +51,10 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) add_library(simdjson-flags INTERFACE) if(MSVC) target_compile_options(simdjson-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS) - target_compile_options(simdjson-flags INTERFACE /W3 /wd4005 /wd4996 /wd4267 /wd4244 /wd4113) + target_compile_options(simdjson-flags INTERFACE /WX /W3 /wd4005 /wd4996 /wd4267 /wd4244 /wd4113) else() target_compile_options(simdjson-flags INTERFACE -fPIC) - target_compile_options(simdjson-flags INTERFACE -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self) + target_compile_options(simdjson-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self) endif() # Optional flags diff --git a/benchmark/bench_dom_api.cpp b/benchmark/bench_dom_api.cpp index bd0633e8..f4a60815 100644 --- a/benchmark/bench_dom_api.cpp +++ b/benchmark/bench_dom_api.cpp @@ -349,8 +349,8 @@ static void twitter_image_sizes(State& state) { auto [media, not_found] = tweet["entities"]["media"]; if (!not_found) { for (dom::object image : media.get()) { - for (auto [key, size] : image["sizes"].get()) { - image_sizes.insert({ size["w"], size["h"] }); + for (auto size : image["sizes"].get()) { + image_sizes.insert({ size.value["w"], size.value["h"] }); } } } @@ -455,9 +455,9 @@ static void error_code_twitter_image_sizes(State& state) noexcept { for (dom::element image : images) { auto [sizes, error2] = image["sizes"].get(); if (error2) { return; } - for (auto [key, size] : sizes) { - auto [width, error3] = size["w"].get(); - auto [height, error4] = size["h"].get(); + for (auto size : sizes) { + auto [width, error3] = size.value["w"].get(); + auto [height, error4] = size.value["h"].get(); if (error3 || error4) { return; } image_sizes.insert({ width, height }); } diff --git a/benchmark/bench_parse_call.cpp b/benchmark/bench_parse_call.cpp index 70f73160..aa0f5d13 100644 --- a/benchmark/bench_parse_call.cpp +++ b/benchmark/bench_parse_call.cpp @@ -22,7 +22,7 @@ static void parser_parse_error_code(State& state) { dom::parser parser; if (parser.allocate(EMPTY_ARRAY.length())) { return; } for (auto _ : state) { - auto [doc, error] = parser.parse(EMPTY_ARRAY); + auto error = parser.parse(EMPTY_ARRAY).error(); if (error) { return; } } } @@ -53,7 +53,7 @@ BENCHMARK(build_parsed_json); static void document_parse_error_code(State& state) { for (auto _ : state) { dom::parser parser; - auto [doc, error] = parser.parse(EMPTY_ARRAY); + auto error = parser.parse(EMPTY_ARRAY).error(); if (error) { return; } } } diff --git a/benchmark/parse_stream.cpp b/benchmark/parse_stream.cpp index dee81c27..0295abd6 100755 --- a/benchmark/parse_stream.cpp +++ b/benchmark/parse_stream.cpp @@ -135,8 +135,6 @@ int main (int argc, char *argv[]){ } - std::min(res.begin(), res.end()); - double min_result = *min_element(res.begin(), res.end()); double speedinGBs = (p.size()) / (min_result * 1000000000.0); diff --git a/benchmark/parseandstatcompetition.cpp b/benchmark/parseandstatcompetition.cpp index 7016d4a2..1cfa448d 100644 --- a/benchmark/parseandstatcompetition.cpp +++ b/benchmark/parseandstatcompetition.cpp @@ -71,6 +71,7 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) { if (element.is()) { s.array_count++; auto [array, array_error] = element.get(); + if (array_error) { std::cerr << array_error << std::endl; abort(); } for (auto child : array) { if (child.is() || child.is()) { simdjson_recurse(s, child); @@ -81,11 +82,12 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) { } else if (element.is()) { s.object_count++; auto [object, object_error] = element.get(); - for (auto [key, value] : object) { - if (value.is() || value.is()) { - simdjson_recurse(s, value); + if (object_error) { std::cerr << object_error << std::endl; abort(); } + for (auto field : object) { + if (field.value.is() || field.value.is()) { + simdjson_recurse(s, field.value); } else { - simdjson_process_atom(s, value); + simdjson_process_atom(s, field.value); } } } else { diff --git a/benchmark/parsingcompetition.cpp b/benchmark/parsingcompetition.cpp index d203f142..28050b07 100644 --- a/benchmark/parsingcompetition.cpp +++ b/benchmark/parsingcompetition.cpp @@ -255,7 +255,7 @@ bool bench(const char *filename, bool verbose, bool just_data, int repeat_multip std::fill(stats.begin(), stats.end(), 0); // unnecessary for (int i = 0; i < repeat; i++) { unified.start(); - auto [doc, parse_error] = parser.parse(p); + auto parse_error = parser.parse(p).error(); if (parse_error) printf("bug\n"); unified.end(results); diff --git a/benchmark/statisticalmodel.cpp b/benchmark/statisticalmodel.cpp index c666a5d7..33ca0cf8 100644 --- a/benchmark/statisticalmodel.cpp +++ b/benchmark/statisticalmodel.cpp @@ -69,6 +69,7 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) { if (element.is()) { s.array_count++; auto [array, array_error] = element.get(); + if (array_error) { std::cerr << array_error << std::endl; abort(); } for (auto child : array) { if (child.is() || child.is()) { simdjson_recurse(s, child); @@ -79,12 +80,13 @@ void simdjson_recurse(stat_t &s, simdjson::dom::element element) { } else if (element.is()) { s.object_count++; auto [object, object_error] = element.get(); - for (auto [key, value] : object) { + if (object_error) { std::cerr << object_error << std::endl; abort(); } + for (auto field : object) { s.string_count++; // for key - if (value.is() || value.is()) { - simdjson_recurse(s, value); + if (field.value.is() || field.value.is()) { + simdjson_recurse(s, field.value); } else { - simdjson_process_atom(s, value); + simdjson_process_atom(s, field.value); } } } else { diff --git a/doc/basics.md b/doc/basics.md index 958e1dec..a76a4404 100644 --- a/doc/basics.md +++ b/doc/basics.md @@ -127,6 +127,7 @@ nicely with C++17's destructuring syntax. For example: dom::parser parser; padded_string json = R"( { "foo": 1, "bar": 2 } )"_padded; auto [object, error] = parser.parse(json).get(); +if (error) { cerr << error << endl; return; } for (auto [key, value] : object) { cout << key << " = " << value << endl; } diff --git a/include/simdjson/common_defs.h b/include/simdjson/common_defs.h index ce82844c..2fc0d4a1 100644 --- a/include/simdjson/common_defs.h +++ b/include/simdjson/common_defs.h @@ -106,10 +106,12 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024; #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \ SIMDJSON_DISABLE_GCC_WARNING(-Wall) \ SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \ + SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \ + SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \ + SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \ SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \ SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \ - SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \ - SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) + SIMDJSON_DISABLE_GCC_WARNING(-Wunused-variable) #define SIMDJSON_PRAGMA(P) _Pragma(#P) #define SIMDJSON_DISABLE_GCC_WARNING(WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING) #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wdeprecated-declarations) diff --git a/include/simdjson/inline/document.h b/include/simdjson/inline/document.h index 7e3fb851..8b34185d 100644 --- a/include/simdjson/inline/document.h +++ b/include/simdjson/inline/document.h @@ -793,7 +793,7 @@ inline simdjson_result element::get() const noexcept { if(is_uint64()) { uint64_t result = next_tape_value(); // Wrapping max in parens to handle Windows issue: https://stackoverflow.com/questions/11544073/how-do-i-deal-with-the-max-macro-in-windows-h-colliding-with-max-in-std - if (result > (std::numeric_limits::max)()) { + if (result > uint64_t((std::numeric_limits::max)())) { return NUMBER_OUT_OF_RANGE; } return static_cast(result); diff --git a/src/arm64/bitmanipulation.h b/src/arm64/bitmanipulation.h index 4c55ef5f..6229d84e 100644 --- a/src/arm64/bitmanipulation.h +++ b/src/arm64/bitmanipulation.h @@ -7,10 +7,10 @@ namespace simdjson { namespace arm64 { -NO_SANITIZE_UNDEFINED // We sometimes call trailing_zero on inputs that are zero, // but the algorithms do not end up using the returned value. // Sadly, sanitizers are not smart enough to figure it out. +NO_SANITIZE_UNDEFINED really_inline int trailing_zeroes(uint64_t input_num) { #ifdef _MSC_VER unsigned long ret; diff --git a/src/generic/atomparsing.h b/src/generic/atomparsing.h index 12cfdbbf..e33292ae 100644 --- a/src/generic/atomparsing.h +++ b/src/generic/atomparsing.h @@ -3,7 +3,7 @@ namespace atomparsing { really_inline uint32_t string_to_uint32(const char* str) { return *reinterpret_cast(str); } WARN_UNUSED -really_inline bool str4ncmp(const uint8_t *src, const char* atom) { +really_inline uint32_t str4ncmp(const uint8_t *src, const char* atom) { uint32_t srcval; // we want to avoid unaligned 64-bit loads (undefined in C/C++) static_assert(sizeof(uint32_t) <= SIMDJSON_PADDING, "SIMDJSON_PADDING must be larger than 4 bytes"); std::memcpy(&srcval, src, sizeof(uint32_t)); diff --git a/src/westmere/bitmanipulation.h b/src/westmere/bitmanipulation.h index 5ebf65ec..ef59bc3f 100644 --- a/src/westmere/bitmanipulation.h +++ b/src/westmere/bitmanipulation.h @@ -10,7 +10,7 @@ namespace westmere { // We sometimes call trailing_zero on inputs that are zero, // but the algorithms do not end up using the returned value. -// Sadly, sanitizers are not smart enough to figure it out. +// Sadly, sanitizers are not smart enough to figure it out. NO_SANITIZE_UNDEFINED really_inline int trailing_zeroes(uint64_t input_num) { #ifdef _MSC_VER diff --git a/tests/allparserscheckfile.cpp b/tests/allparserscheckfile.cpp index 30cec796..9278b4fc 100644 --- a/tests/allparserscheckfile.cpp +++ b/tests/allparserscheckfile.cpp @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) { std::cout << std::endl; } simdjson::dom::parser parser; - auto [doc, err] = parser.parse(p); + auto err = parser.parse(p).error(); rapidjson::Document d; diff --git a/tests/basictests.cpp b/tests/basictests.cpp index 8b6c983c..62c59613 100644 --- a/tests/basictests.cpp +++ b/tests/basictests.cpp @@ -54,18 +54,14 @@ namespace number_tests { bool small_integers() { std::cout << __func__ << std::endl; - char buf[1024]; simdjson::dom::parser parser; for (int m = 10; m < 20; m++) { for (int i = -1024; i < 1024; i++) { - auto n = sprintf(buf, "%*d", m, i); - buf[n] = '\0'; - fflush(NULL); - - auto [actual, error] = parser.parse(buf, n).get(); + auto str = std::to_string(i); + auto [actual, error] = parser.parse(str).get(); if (error) { std::cerr << error << std::endl; return false; } if (actual != i) { - std::cerr << "JSON '" << buf << " parsed to " << actual << " instead of " << i << std::endl; + std::cerr << "JSON '" << str << "' parsed to " << actual << " instead of " << i << std::endl; return false; } } @@ -202,7 +198,7 @@ namespace document_tests { std::cout << __func__ << std::endl; simdjson::padded_string badjson = "[7,7,7,7,6,7,7,7,6,7,7,6,[7,7,7,7,6,7,7,7,6,7,7,6,7,7,7,7,7,7,6"_padded; simdjson::dom::parser parser; - auto [doc, error] = parser.parse(badjson); + auto error = parser.parse(badjson).error(); if (!error) { printf("This json should not be valid %s.\n", badjson.data()); return false; @@ -313,16 +309,16 @@ namespace document_tests { fflush(NULL); } counter++; - auto [doc1, res1] = parser.parse(rec.c_str(), rec.length()); - if (res1 != simdjson::error_code::SUCCESS) { + auto error = parser.parse(rec.c_str(), rec.length()).error(); + if (error != simdjson::error_code::SUCCESS) { printf("Something is wrong in skyprophet_test: %s.\n", rec.c_str()); - printf("Parsing failed. Error is %s\n", simdjson::error_message(res1)); + printf("Parsing failed. Error is %s\n", simdjson::error_message(error)); return false; } - auto [doc2, res2] = parser.parse(rec.c_str(), rec.length()); - if (res2 != simdjson::error_code::SUCCESS) { + error = parser.parse(rec.c_str(), rec.length()).error(); + if (error != simdjson::error_code::SUCCESS) { printf("Something is wrong in skyprophet_test: %s.\n", rec.c_str()); - printf("Parsing failed. Error is %s\n", simdjson::error_message(res2)); + printf("Parsing failed. Error is %s\n", simdjson::error_message(error)); return false; } } @@ -338,7 +334,7 @@ namespace document_tests { input += "]"; } simdjson::dom::parser parser; - auto [doc, error] = parser.parse(input); + auto error = parser.parse(input).error(); if (error) { std::cerr << "Error: " << simdjson::error_message(error) << std::endl; return false; } return true; } @@ -353,7 +349,6 @@ namespace document_tests { } namespace document_stream_tests { - static simdjson::dom::document_stream parse_many_stream_return(simdjson::dom::parser &parser, simdjson::padded_string &str) { return parser.parse_many(str); } @@ -367,9 +362,9 @@ namespace document_stream_tests { static bool parse_json_message_issue467(simdjson::padded_string &json, size_t expectedcount) { simdjson::dom::parser parser; size_t count = 0; - for (auto [doc, error] : parser.parse_many(json)) { - if (error) { - std::cerr << "Failed with simdjson error= " << error << std::endl; + for (auto doc : parser.parse_many(json)) { + if (doc.error()) { + std::cerr << "Failed with simdjson error= " << doc.error() << std::endl; return false; } count++; @@ -973,11 +968,11 @@ namespace dom_api_tests { object sizes; image["sizes"].get().tie(sizes, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0; if (error) { cerr << "Error: " << error << endl; return false; } - for (auto [key, size] : sizes) { + for (auto size : sizes) { uint64_t width, height; - size["w"].get().tie(width, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0; + size.value["w"].get().tie(width, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0; if (error) { cerr << "Error: " << error << endl; return false; } - size["h"].get().tie(height, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0; + size.value["h"].get().tie(height, error); // tie(...) = fails with "no viable overloaded '='" on Apple clang version 11.0.0; if (error) { cerr << "Error: " << error << endl; return false; } image_sizes.insert(make_pair(width, height)); } @@ -1134,8 +1129,8 @@ namespace dom_api_tests { auto [media, not_found] = tweet["entities"]["media"]; if (!not_found) { for (object image : media.get()) { - for (auto [key, size] : image["sizes"].get()) { - image_sizes.insert(make_pair(size["w"], size["h"])); + for (auto size : image["sizes"].get()) { + image_sizes.insert(make_pair(size.value["w"], size.value["h"])); } } } @@ -1712,6 +1707,7 @@ namespace format_tests { std::cout << "Running " << __func__ << std::endl; dom::parser parser; auto [value, error] = parser.parse(DOCUMENT)["foo"]; + if (error) { cerr << error << endl; return false; } ostringstream s; s << value; return assert_minified(s, "1"); @@ -1720,6 +1716,7 @@ namespace format_tests { std::cout << "Running " << __func__ << std::endl; dom::parser parser; auto [value, error] = parser.parse(DOCUMENT)["foo"]; + if (error) { cerr << error << endl; return false; } ostringstream s; s << minify(value); return assert_minified(s, "1"); @@ -1729,6 +1726,7 @@ namespace format_tests { std::cout << "Running " << __func__ << std::endl; dom::parser parser; auto [value, error] = parser.parse(DOCUMENT)["bar"].get(); + if (error) { cerr << error << endl; return false; } ostringstream s; s << value; return assert_minified(s, "[1,2,3]"); @@ -1737,6 +1735,7 @@ namespace format_tests { std::cout << "Running " << __func__ << std::endl; dom::parser parser; auto [value, error] = parser.parse(DOCUMENT)["bar"].get(); + if (error) { cerr << error << endl; return false; } ostringstream s; s << minify(value); return assert_minified(s, "[1,2,3]"); @@ -1746,6 +1745,7 @@ namespace format_tests { std::cout << "Running " << __func__ << std::endl; dom::parser parser; auto [value, error] = parser.parse(DOCUMENT)["baz"].get(); + if (error) { cerr << error << endl; return false; } ostringstream s; s << value; return assert_minified(s, R"({"a":1,"b":2,"c":3})"); @@ -1754,6 +1754,7 @@ namespace format_tests { std::cout << "Running " << __func__ << std::endl; dom::parser parser; auto [value, error] = parser.parse(DOCUMENT)["baz"].get(); + if (error) { cerr << error << endl; return false; } ostringstream s; s << minify(value); return assert_minified(s, R"({"a":1,"b":2,"c":3})"); diff --git a/tests/errortests.cpp b/tests/errortests.cpp index 525e7b11..80f5823c 100644 --- a/tests/errortests.cpp +++ b/tests/errortests.cpp @@ -28,15 +28,15 @@ namespace parser_load { bool parser_load_capacity() { TEST_START(); dom::parser parser(1); // 1 byte max capacity - auto [doc, error] = parser.load(TWITTER_JSON); + auto error = parser.load(TWITTER_JSON).error(); ASSERT_ERROR(error, CAPACITY); TEST_SUCCEED(); } bool parser_load_many_capacity() { TEST_START(); dom::parser parser(1); // 1 byte max capacity - for (auto [doc, error] : parser.load_many(TWITTER_JSON)) { - ASSERT_ERROR(error, CAPACITY); + for (auto doc : parser.load_many(TWITTER_JSON)) { + ASSERT_ERROR(doc.error(), CAPACITY); TEST_SUCCEED(); } TEST_FAIL("No documents returned"); @@ -45,22 +45,22 @@ namespace parser_load { bool parser_load_nonexistent() { TEST_START(); dom::parser parser; - auto [doc, error] = parser.load(NONEXISTENT_FILE); + auto error = parser.load(NONEXISTENT_FILE).error(); ASSERT_ERROR(error, IO_ERROR); TEST_SUCCEED(); } bool parser_load_many_nonexistent() { TEST_START(); dom::parser parser; - for (auto [doc, error] : parser.load_many(NONEXISTENT_FILE)) { - ASSERT_ERROR(error, IO_ERROR); + for (auto doc : parser.load_many(NONEXISTENT_FILE)) { + ASSERT_ERROR(doc.error(), IO_ERROR); TEST_SUCCEED(); } TEST_FAIL("No documents returned"); } bool padded_string_load_nonexistent() { TEST_START(); - auto [str, error] = padded_string::load(NONEXISTENT_FILE); + auto error = padded_string::load(NONEXISTENT_FILE).error(); ASSERT_ERROR(error, IO_ERROR); TEST_SUCCEED(); } @@ -68,7 +68,7 @@ namespace parser_load { bool parser_load_chain() { TEST_START(); dom::parser parser; - auto [val, error] = parser.load(NONEXISTENT_FILE)["foo"].get(); + auto error = parser.load(NONEXISTENT_FILE)["foo"].get().error(); ASSERT_ERROR(error, IO_ERROR); TEST_SUCCEED(); } @@ -76,7 +76,7 @@ namespace parser_load { TEST_START(); dom::parser parser; for (auto doc : parser.load_many(NONEXISTENT_FILE)) { - auto [val, error] = doc["foo"].get(); + auto error = doc["foo"].get().error(); ASSERT_ERROR(error, IO_ERROR); TEST_SUCCEED(); } diff --git a/tests/jsoncheck.cpp b/tests/jsoncheck.cpp index 5ab4b06c..13b85f9a 100644 --- a/tests/jsoncheck.cpp +++ b/tests/jsoncheck.cpp @@ -70,7 +70,7 @@ bool validate(const char *dirname) { return EXIT_FAILURE; } simdjson::dom::parser parser; - auto [doc, errorcode] = parser.parse(p); + auto errorcode = parser.parse(p).error(); ++how_many; printf("%s\n", errorcode == simdjson::error_code::SUCCESS ? "ok" : "invalid"); if (contains("EXCLUDE", name)) { diff --git a/tests/numberparsingcheck.cpp b/tests/numberparsingcheck.cpp index 98f313fa..5cd663b6 100644 --- a/tests/numberparsingcheck.cpp +++ b/tests/numberparsingcheck.cpp @@ -179,7 +179,7 @@ bool validate(const char *dirname) { invalid_count = 0; total_count += float_count + int_count + invalid_count; simdjson::dom::parser parser; - auto [doc, err] = parser.parse(p); + auto err = parser.parse(p).error(); bool isok = (err == simdjson::error_code::SUCCESS); if (int_count + float_count + invalid_count > 0) { printf("File %40s %s --- integers: %10zu floats: %10zu invalid: %10zu " diff --git a/tests/pointercheck.cpp b/tests/pointercheck.cpp index 1b3a719f..58e67ce3 100644 --- a/tests/pointercheck.cpp +++ b/tests/pointercheck.cpp @@ -44,7 +44,7 @@ bool json_pointer_success_test(const char *json_pointer, std::string_view expect bool json_pointer_success_test(const char *json_pointer) { std::cout << "Running successful JSON pointer test '" << json_pointer << "' ..." << std::endl; dom::parser parser; - auto [value, error] = parser.parse(TEST_JSON).at(json_pointer); + auto error = parser.parse(TEST_JSON).at(json_pointer).error(); if (error) { std::cerr << "Unexpected Error: " << error << std::endl; return false; } return true; } @@ -53,7 +53,7 @@ bool json_pointer_success_test(const char *json_pointer) { bool json_pointer_failure_test(const char *json_pointer, error_code expected_failure_test) { std::cout << "Running invalid JSON pointer test '" << json_pointer << "' ..." << std::endl; dom::parser parser; - auto [value, error] = parser.parse(TEST_JSON).at(json_pointer); + auto error = parser.parse(TEST_JSON).at(json_pointer).error(); ASSERT(error == expected_failure_test); return true; } diff --git a/tests/readme_examples.cpp b/tests/readme_examples.cpp index 88fcc404..bee89dac 100644 --- a/tests/readme_examples.cpp +++ b/tests/readme_examples.cpp @@ -114,6 +114,7 @@ void basics_cpp17_1() { dom::parser parser; padded_string json = R"( { "foo": 1, "bar": 2 } )"_padded; auto [object, error] = parser.parse(json).get(); + if (error) { cerr << error << endl; return; } for (auto [key, value] : object) { cout << key << " = " << value << endl; } @@ -180,6 +181,7 @@ void performance_1() { } #ifdef SIMDJSON_CPLUSPLUS17 +SIMDJSON_PUSH_DISABLE_ALL_WARNINGS // The web_request part of this is aspirational, so we compile as much as we can here void performance_2() { dom::parser parser(1024*1024); // Never grow past documents > 1MB @@ -204,6 +206,7 @@ void performance_3() { // ... // } } +SIMDJSON_POP_DISABLE_WARNINGS #endif int main() { diff --git a/tests/readme_examples_noexceptions.cpp b/tests/readme_examples_noexceptions.cpp index 473cac17..0b5cd677 100644 --- a/tests/readme_examples_noexceptions.cpp +++ b/tests/readme_examples_noexceptions.cpp @@ -5,6 +5,7 @@ using namespace std; using namespace simdjson; #ifdef SIMDJSON_CPLUSPLUS17 +SIMDJSON_PUSH_DISABLE_ALL_WARNINGS void basics_error_1() { dom::parser parser; auto json = "1"_padded; @@ -13,6 +14,7 @@ void basics_error_1() { if (error) { cerr << error << endl; exit(1); } // Use document here now that we've checked for the error } +SIMDJSON_POP_DISABLE_WARNINGS #endif void basics_error_2() { diff --git a/tests/stringparsingcheck.cpp b/tests/stringparsingcheck.cpp index 7ceff729..47f96199 100644 --- a/tests/stringparsingcheck.cpp +++ b/tests/stringparsingcheck.cpp @@ -348,7 +348,7 @@ bool validate(const char *dirname) { total_string_length = 0; empty_string = 0; simdjson::dom::parser parser; - auto [doc, err] = parser.parse(p); + auto err = parser.parse(p).error(); bool isok = (err == simdjson::error_code::SUCCESS); free(big_buffer); if (good_string > 0) {