Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed May 19, 2020
1 parent e49288b commit a412606
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cmake/toolchains/msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions include/boost/json/basic_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -2242,4 +2247,8 @@ write_some(
} // json
} // boost

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif
2 changes: 1 addition & 1 deletion include/boost/json/detail/counted_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class counted_resource_impl final

bool
do_is_equal(
memory_resource const& mr) const noexcept override
memory_resource const&) const noexcept override
{
// VFALCO Is always false ok?
return false;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/json/detail/default_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class default_resource final
void*
do_allocate(
std::size_t n,
std::size_t align) override
std::size_t) override
{
return ::operator new(n);
}
Expand Down
2 changes: 1 addition & 1 deletion include/boost/json/detail/impl/format.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/boost/json/detail/sse2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions include/boost/json/impl/parser.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions include/boost/json/impl/serializer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -797,4 +802,8 @@ operator<<( std::ostream& os, value const& jv )
} // json
} // boost

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif
2 changes: 1 addition & 1 deletion include/boost/json/monotonic_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
9 changes: 6 additions & 3 deletions test/monotonic_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,16 @@ class monotonic_resource_test
{
{
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));
}
}
Expand Down
51 changes: 25 additions & 26 deletions test/snippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -101,7 +112,6 @@ usingInitLists()
{ "account-balances", { 84, 120, 126 } } };

//]
(void)jv;
}

{
Expand All @@ -116,7 +126,6 @@ usingInitLists()
assert( to_string(jv) == "[true,2,\"hello\",null]" );

//]
(void)jv;
}

{
Expand All @@ -131,7 +140,6 @@ usingInitLists()
assert( to_string(jv) == "[true,2,\"hello\",[\"bye\",null,false]]" );

//]
(void)jv;
}

{
Expand All @@ -141,7 +149,6 @@ usingInitLists()
value jv = { { "hello", 42 }, { "world", 43 } };

//]
(void)jv;
}

{
Expand All @@ -166,10 +173,6 @@ usingInitLists()
assert( jv2.is_array() && jv3.is_array() && jv4.is_array() );

//]
(void)jv1;
(void)jv2;
(void)jv3;
(void)jv4;
}

{
Expand All @@ -186,7 +189,6 @@ usingInitLists()
assert ( to_string(jv) == R"([["hello",42],["world",43]])" );

//]
(void)jv;
}

{
Expand All @@ -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;
}

{
Expand All @@ -220,7 +220,6 @@ usingInitLists()
assert( jo["venus"].is_array() );

//]
(void)jo;
}

{
Expand All @@ -237,8 +236,6 @@ usingInitLists()
assert( to_string(jv) == R"({"clients":{"john":100,"dave":500,"joe":300}})" );

//]
(void)jo1;
(void)jv;
}
}

Expand Down Expand Up @@ -741,18 +738,20 @@ class snippets_test
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();
}
};
Expand Down
9 changes: 0 additions & 9 deletions test/value_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,6 @@ class value_ref_test
}
}

struct FT
{
value
to_value(storage_ptr sp) const
{
return nullptr;
}
};

void
run()
{
Expand Down

0 comments on commit a412606

Please sign in to comment.