2
0
mirror of https://github.com/boostorg/json.git synced 2026-01-19 04:12:14 +00:00

Fix warnings

This commit is contained in:
Vinnie Falco
2020-05-19 11:27:29 -07:00
parent e49288be75
commit a412606a72
12 changed files with 59 additions and 48 deletions

View File

@@ -7,7 +7,7 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STR
# Compiler options.
add_compile_options(
/permissive- # strict C++
/W3 # enable all warnings
/W4 # enable all warnings
/MP # multi-processor compilation
)
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32") # 32-bit

View File

@@ -18,6 +18,11 @@
#include <cmath>
#include <cstring>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#endif
/* This file must be manually included to get the
function template definitions for basic_parser.
*/
@@ -2242,4 +2247,8 @@ write_some(
} // json
} // boost
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif

View File

@@ -57,7 +57,7 @@ public:
bool
do_is_equal(
memory_resource const& mr) const noexcept override
memory_resource const&) const noexcept override
{
// VFALCO Is always false ok?
return false;

View File

@@ -26,7 +26,7 @@ public:
void*
do_allocate(
std::size_t n,
std::size_t align) override
std::size_t) override
{
return ::operator new(n);
}

View File

@@ -53,7 +53,7 @@ inline void format_two_digits( char * dest, unsigned v )
inline void format_digit( char * dest, unsigned v )
{
*dest = v + '0';
*dest = static_cast<char>( v + '0' );
}
unsigned

View File

@@ -289,14 +289,14 @@ inline std::size_t count_whitespace( char const * p, std::size_t n ) noexcept
if( m != 0 )
{
#if defined(__GNUC__) || defined(__clang__)
std::size_t n = __builtin_ffs( m ) - 1;
std::size_t c = __builtin_ffs( m ) - 1;
#else
unsigned long index;
_BitScanForward( &index, m );
std::size_t n = index;
std::size_t c = index;
#endif
p += n;
p += c;
return p - p0;
}

View File

@@ -442,7 +442,7 @@ on_document_end(error_code&)
bool
parser::
on_object_begin(error_code& ec)
on_object_begin(error_code&)
{
// prevent splits from exceptions
rs_.prepare(
@@ -476,7 +476,7 @@ on_object_end(
bool
parser::
on_array_begin(error_code& ec)
on_array_begin(error_code&)
{
// prevent splits from exceptions
rs_.prepare(

View File

@@ -15,6 +15,11 @@
#include <boost/json/detail/sse2.hpp>
#include <ostream>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#endif
namespace boost {
namespace json {
@@ -797,4 +802,8 @@ operator<<( std::ostream& os, value const& jv )
} // json
} // boost
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif

View File

@@ -48,7 +48,7 @@ class monotonic_resource final
initial_block initial_;
static std::size_t const min_block_size_ = 1024;
static std::size_t const max_block_size_ = -1;
static std::size_t const max_block_size_ = std::size_t(-1);
template<typename Block>
void*

View File

@@ -116,13 +116,16 @@ public:
{
{
monotonic_resource mr;
mr.allocate(2048);
auto p = mr.allocate(2048);
(void)p;
BOOST_TEST(all_alloc_in_same_block(mr, 4096, 1));
}
{
monotonic_resource mr;
mr.allocate(2000, 1);
mr.allocate(48, 1);
void* p;
p = mr.allocate(2000, 1);
p = mr.allocate(48, 1);
(void)p;
BOOST_TEST(all_alloc_in_same_block(mr, 4096, 1));
}
}

View File

@@ -14,6 +14,17 @@
#include "test_suite.hpp"
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4101)
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused"
#endif
namespace boost {
namespace json {
@@ -101,7 +112,6 @@ usingInitLists()
{ "account-balances", { 84, 120, 126 } } };
//]
(void)jv;
}
{
@@ -116,7 +126,6 @@ usingInitLists()
assert( to_string(jv) == "[true,2,\"hello\",null]" );
//]
(void)jv;
}
{
@@ -131,7 +140,6 @@ usingInitLists()
assert( to_string(jv) == "[true,2,\"hello\",[\"bye\",null,false]]" );
//]
(void)jv;
}
{
@@ -141,7 +149,6 @@ usingInitLists()
value jv = { { "hello", 42 }, { "world", 43 } };
//]
(void)jv;
}
{
@@ -166,10 +173,6 @@ usingInitLists()
assert( jv2.is_array() && jv3.is_array() && jv4.is_array() );
//]
(void)jv1;
(void)jv2;
(void)jv3;
(void)jv4;
}
{
@@ -186,7 +189,6 @@ usingInitLists()
assert ( to_string(jv) == R"([["hello",42],["world",43]])" );
//]
(void)jv;
}
{
@@ -201,13 +203,11 @@ usingInitLists()
array ja = { { "mercury", 36 }, { "venus", 67 }, { "earth", 93 } };
for (value& jv2 : ja)
assert( jv2.is_array() );
assert( jv2.is_array() );
assert( to_string(ja) == "[[\"mercury\",36],[\"venus\",67],[\"earth\",93]]" );
//]
(void)jv1;
(void)ja;
}
{
@@ -220,7 +220,6 @@ usingInitLists()
assert( jo["venus"].is_array() );
//]
(void)jo;
}
{
@@ -237,8 +236,6 @@ usingInitLists()
assert( to_string(jv) == R"({"clients":{"john":100,"dave":500,"joe":300}})" );
//]
(void)jo1;
(void)jv;
}
}
@@ -741,18 +738,20 @@ public:
void
run()
{
(void)&usingStrings;
usingInitLists();
(void)&usingArrays;
(void)&usingObjects;
(void)&usingStorage;
(void)&parse_fast;
(void)&do_json;
(void)&do_rpc;
(void)&usingParsing;
(void)&usingSerializing;
(void)&usingExchange1;
(void)&usingExchange2;
&usingStrings;
&usingArrays;
&usingObjects;
&usingStorage;
&parse_fast;
&do_json;
&do_rpc;
&usingParsing;
&usingSerializing;
&usingExchange1;
&usingExchange2;
BOOST_TEST_PASS();
}
};

View File

@@ -337,15 +337,6 @@ public:
}
}
struct FT
{
value
to_value(storage_ptr sp) const
{
return nullptr;
}
};
void
run()
{