mirror of
https://github.com/nlohmann/json.git
synced 2026-11-22 02:44:22 +00:00
Route the -Wduplicated-branches pragma through Hedley
Match #5485, which moved the binary writer's hand-rolled diagnostic pragmas onto JSON_HEDLEY_PRAGMA (merged into develop while this branch was open). The devirtualization's -Wduplicated-branches suppression in write_compact_float was the one raw '#pragma GCC diagnostic' left; it now uses JSON_HEDLEY_PRAGMA like the adjacent -Wfloat-equal line, still guarded to GCC >= 7 and non-clang (the warning exists only there). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAYM1qhSA2FDaDcGfPW3fG Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+356
-194
No files matched your search
@@ -313,8 +313,8 @@ class binary_writer
|
|||||||
|
|
||||||
// step 2: write the string
|
// step 2: write the string
|
||||||
oa.write_characters(
|
oa.write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_data.m_value.string->data()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.string->data()),
|
||||||
j.m_data.m_value.string->size());
|
j.m_data.m_value.string->size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,8 +633,8 @@ class binary_writer
|
|||||||
|
|
||||||
// step 2: write the string
|
// step 2: write the string
|
||||||
oa.write_characters(
|
oa.write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_data.m_value.string->data()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.string->data()),
|
||||||
j.m_data.m_value.string->size());
|
j.m_data.m_value.string->size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,8 +850,8 @@ class binary_writer
|
|||||||
}
|
}
|
||||||
write_number_with_ubjson_prefix(j.m_data.m_value.string->size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(j.m_data.m_value.string->size(), true, use_bjdata);
|
||||||
oa.write_characters(
|
oa.write_characters(
|
||||||
reinterpret_cast<const CharType*>(j.m_data.m_value.string->data()),
|
reinterpret_cast<const CharType*>(j.m_data.m_value.string->data()),
|
||||||
j.m_data.m_value.string->size());
|
j.m_data.m_value.string->size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1012,8 +1012,8 @@ class binary_writer
|
|||||||
{
|
{
|
||||||
write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata);
|
write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata);
|
||||||
oa.write_characters(
|
oa.write_characters(
|
||||||
reinterpret_cast<const CharType*>(el.first.data()),
|
reinterpret_cast<const CharType*>(el.first.data()),
|
||||||
el.first.size());
|
el.first.size());
|
||||||
write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
|
write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,8 +1075,8 @@ class binary_writer
|
|||||||
{
|
{
|
||||||
oa.write_character(to_char_type(element_type));
|
oa.write_character(to_char_type(element_type));
|
||||||
oa.write_characters(
|
oa.write_characters(
|
||||||
reinterpret_cast<const CharType*>(name.data()),
|
reinterpret_cast<const CharType*>(name.data()),
|
||||||
name.size());
|
name.size());
|
||||||
// the terminating null byte is written explicitly rather than taken
|
// the terminating null byte is written explicitly rather than taken
|
||||||
// from the buffer, so that string_t::data() need not be null-terminated
|
// from the buffer, so that string_t::data() need not be null-terminated
|
||||||
oa.write_character(to_char_type(0x00));
|
oa.write_character(to_char_type(0x00));
|
||||||
@@ -1120,8 +1120,8 @@ class binary_writer
|
|||||||
|
|
||||||
write_number<std::int32_t>(to_bson_length(value.size() + 1ul), true);
|
write_number<std::int32_t>(to_bson_length(value.size() + 1ul), true);
|
||||||
oa.write_characters(
|
oa.write_characters(
|
||||||
reinterpret_cast<const CharType*>(value.data()),
|
reinterpret_cast<const CharType*>(value.data()),
|
||||||
value.size());
|
value.size());
|
||||||
// the terminating null byte is written explicitly rather than taken
|
// the terminating null byte is written explicitly rather than taken
|
||||||
// from the buffer, so that string_t::data() need not be null-terminated
|
// from the buffer, so that string_t::data() need not be null-terminated
|
||||||
oa.write_character(to_char_type(0x00));
|
oa.write_character(to_char_type(0x00));
|
||||||
@@ -2107,7 +2107,7 @@ class binary_writer
|
|||||||
// (-Wduplicated-branches only exists from GCC 7 on; naming it on an older
|
// (-Wduplicated-branches only exists from GCC 7 on; naming it on an older
|
||||||
// GCC would itself warn under -Wpragmas)
|
// GCC would itself warn under -Wpragmas)
|
||||||
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
|
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
|
||||||
#pragma GCC diagnostic ignored "-Wduplicated-branches"
|
JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wduplicated-branches")
|
||||||
#endif
|
#endif
|
||||||
if (!std::isfinite(n) || ((static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
|
if (!std::isfinite(n) || ((static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
|
||||||
static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
|
static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
|
||||||
|
|||||||
+343
-181
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user