Fix GCC 7 warning when inlining does its job
This commit is contained in:
parent
dfc510f009
commit
a1cf588d5f
|
@ -100,6 +100,7 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_VS_WARNING(4996)
|
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_VS_WARNING(4996)
|
||||||
|
#define SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING
|
||||||
#define SIMDJSON_POP_DISABLE_WARNINGS __pragma(warning( pop ))
|
#define SIMDJSON_POP_DISABLE_WARNINGS __pragma(warning( pop ))
|
||||||
|
|
||||||
#else // SIMDJSON_REGULAR_VISUAL_STUDIO
|
#else // SIMDJSON_REGULAR_VISUAL_STUDIO
|
||||||
|
@ -139,6 +140,7 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
|
||||||
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
||||||
#endif
|
#endif
|
||||||
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wdeprecated-declarations)
|
#define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wdeprecated-declarations)
|
||||||
|
#define SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING SIMDJSON_DISABLE_GCC_WARNING(-Wstrict-overflow)
|
||||||
#define SIMDJSON_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")
|
#define SIMDJSON_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,11 @@ simdjson_really_inline json_iterator::json_iterator(ondemand::parser *_parser) n
|
||||||
logger::log_headers();
|
logger::log_headers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GCC 7 warns when the first line of this function is inlined away into oblivion due to the caller
|
||||||
|
// relating depth and parent_depth, which is a desired effect. The warning does not show up if the
|
||||||
|
// skip_child() function is not marked inline).
|
||||||
|
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||||
|
SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING
|
||||||
simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip_child(depth_t parent_depth) noexcept {
|
simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip_child(depth_t parent_depth) noexcept {
|
||||||
if (depth() <= parent_depth) { return SUCCESS; }
|
if (depth() <= parent_depth) { return SUCCESS; }
|
||||||
|
|
||||||
|
@ -90,6 +95,8 @@ simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip_child
|
||||||
return report_error(TAPE_ERROR, "not enough close braces");
|
return report_error(TAPE_ERROR, "not enough close braces");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
simdjson_really_inline bool json_iterator::at_root() const noexcept {
|
simdjson_really_inline bool json_iterator::at_root() const noexcept {
|
||||||
return token.checkpoint() == root_checkpoint();
|
return token.checkpoint() == root_checkpoint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ namespace dom_api_tests {
|
||||||
ASSERT_ERROR( object["d"], NO_SUCH_FIELD );
|
ASSERT_ERROR( object["d"], NO_SUCH_FIELD );
|
||||||
return true;
|
return true;
|
||||||
}));
|
}));
|
||||||
SUBTEST("ondemand::value", test_ondemand_doc(json, [&](auto doc_result) {
|
SUBTEST("simdjson_result<ondemand::value>", test_ondemand_doc(json, [&](auto doc_result) {
|
||||||
simdjson_result<ondemand::value> object = doc_result["outer"];
|
simdjson_result<ondemand::value> object = doc_result["outer"];
|
||||||
ASSERT_EQUAL( object["a"].get_uint64().first, 1 );
|
ASSERT_EQUAL( object["a"].get_uint64().first, 1 );
|
||||||
ASSERT_EQUAL( object["b"].get_uint64().first, 2 );
|
ASSERT_EQUAL( object["b"].get_uint64().first, 2 );
|
||||||
|
@ -1690,7 +1690,7 @@ namespace ordering_tests {
|
||||||
}
|
}
|
||||||
return (x == 1.1) && (y == 2.2) && (z == 3.3);
|
return (x == 1.1) && (y == 2.2) && (z == 3.3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
bool run() {
|
bool run() {
|
||||||
return
|
return
|
||||||
|
@ -1725,6 +1725,7 @@ namespace twitter_tests {
|
||||||
}));
|
}));
|
||||||
TEST_SUCCEED();
|
TEST_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SIMDJSON_EXCEPTIONS
|
#if SIMDJSON_EXCEPTIONS
|
||||||
bool twitter_example() {
|
bool twitter_example() {
|
||||||
TEST_START();
|
TEST_START();
|
||||||
|
@ -1746,7 +1747,7 @@ namespace twitter_tests {
|
||||||
}
|
}
|
||||||
TEST_SUCCEED();
|
TEST_SUCCEED();
|
||||||
}
|
}
|
||||||
#endif
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
bool twitter_default_profile() {
|
bool twitter_default_profile() {
|
||||||
TEST_START();
|
TEST_START();
|
||||||
|
@ -1785,11 +1786,21 @@ namespace twitter_tests {
|
||||||
auto media = tweet["entities"]["media"];
|
auto media = tweet["entities"]["media"];
|
||||||
if (!media.error()) {
|
if (!media.error()) {
|
||||||
for (auto image : media) {
|
for (auto image : media) {
|
||||||
|
uint64_t id_val;
|
||||||
|
std::string_view id_string;
|
||||||
|
ASSERT_SUCCESS( image["id"].get(id_val) );
|
||||||
|
ASSERT_SUCCESS( image["id_str"].get(id_string) );
|
||||||
|
std::cout << "id = " << id_val << std::endl;
|
||||||
|
std::cout << "id_string = " << id_string << std::endl;
|
||||||
|
|
||||||
for (auto size : image["sizes"].get_object()) {
|
for (auto size : image["sizes"].get_object()) {
|
||||||
auto size_value = size.value().get_object();
|
std::string_view size_key;
|
||||||
|
ASSERT_SUCCESS( size.unescaped_key().get(size_key) );
|
||||||
|
std::cout << "Type of image size = " << size_key << std::endl;
|
||||||
|
|
||||||
uint64_t width, height;
|
uint64_t width, height;
|
||||||
ASSERT_SUCCESS( size_value["w"].get(width) );
|
ASSERT_SUCCESS( size.value()["w"].get(width) );
|
||||||
ASSERT_SUCCESS( size_value["h"].get(height) );
|
ASSERT_SUCCESS( size.value()["h"].get(height) );
|
||||||
image_sizes.insert(make_pair(width, height));
|
image_sizes.insert(make_pair(width, height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1836,6 +1847,14 @@ namespace twitter_tests {
|
||||||
TEST_SUCCEED();
|
TEST_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fun fact: id and id_str can differ:
|
||||||
|
* 505866668485386240 and 505866668485386241.
|
||||||
|
* Presumably, it is because doubles are used
|
||||||
|
* at some point in the process and the number
|
||||||
|
* 505866668485386241 cannot be represented as a double.
|
||||||
|
* (not our fault)
|
||||||
|
*/
|
||||||
bool twitter_image_sizes_exception() {
|
bool twitter_image_sizes_exception() {
|
||||||
TEST_START();
|
TEST_START();
|
||||||
padded_string json = padded_string::load(TWITTER_JSON);
|
padded_string json = padded_string::load(TWITTER_JSON);
|
||||||
|
@ -1845,30 +1864,13 @@ namespace twitter_tests {
|
||||||
for (auto tweet : doc_result["statuses"]) {
|
for (auto tweet : doc_result["statuses"]) {
|
||||||
auto media = tweet["entities"]["media"];
|
auto media = tweet["entities"]["media"];
|
||||||
if (!media.error()) {
|
if (!media.error()) {
|
||||||
for (ondemand::object image : media) {
|
for (auto image : media) {
|
||||||
/**
|
std::cout << "id = " << uint64_t(image["id"]) << std::endl;
|
||||||
* Fun fact: id and id_str can differ:
|
std::cout << "id_string = " << std::string_view(image["id_str"]) << std::endl;
|
||||||
* 505866668485386240 and 505866668485386241.
|
|
||||||
* Presumably, it is because doubles are used
|
|
||||||
* at some point in the process and the number
|
|
||||||
* 505866668485386241 cannot be represented as a double.
|
|
||||||
* (not our fault)
|
|
||||||
*/
|
|
||||||
uint64_t id_val = image["id"];
|
|
||||||
std::cout << "id = " << id_val << std::endl;
|
|
||||||
std::string_view id_string = image["id_str"];
|
|
||||||
std::cout << "id_string = " << id_string << std::endl;
|
|
||||||
for (auto size : image["sizes"].get_object()) {
|
for (auto size : image["sizes"].get_object()) {
|
||||||
/**
|
std::cout << "Type of image size = " << std::string_view(size.unescaped_key()) << std::endl;
|
||||||
* We want to know the key that describes the size.
|
// NOTE: the uint64_t is required so that each value is actually parsed before the pair is created
|
||||||
*/
|
image_sizes.insert(make_pair<uint64_t,uint64_t>(size.value()["w"], size.value()["h"]));
|
||||||
std::string_view raw_size_key_v = size.unescaped_key();
|
|
||||||
std::cout << "Type of image size = " << raw_size_key_v << std::endl;
|
|
||||||
ondemand::object size_value = size.value();
|
|
||||||
int64_t width = size_value["w"];
|
|
||||||
int64_t height = size_value["h"];
|
|
||||||
std::cout << width << " x " << height << std::endl;
|
|
||||||
image_sizes.insert(make_pair(width, height));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1879,7 +1881,7 @@ namespace twitter_tests {
|
||||||
TEST_SUCCEED();
|
TEST_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
bool run() {
|
bool run() {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue