Skip to content

Commit 7c8f0a4

Browse files
authored
Merge pull request #785 from jseward/develop
Fix warning C4706 on Visual Studio 2017 - fixes #784
2 parents b27a142 + af99090 commit 7c8f0a4

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

src/json.hpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,11 +3034,19 @@ class parser
30343034
{
30353035
case token_type::begin_object:
30363036
{
3037-
if (keep and (not callback or ((keep = callback(depth++, parse_event_t::object_start, result)))))
3037+
if (keep)
30383038
{
3039-
// explicitly set result to object to cope with {}
3040-
result.m_type = value_t::object;
3041-
result.m_value = value_t::object;
3039+
if (callback)
3040+
{
3041+
keep = callback(depth++, parse_event_t::object_start, result);
3042+
}
3043+
3044+
if (not callback or keep)
3045+
{
3046+
// explicitly set result to object to cope with {}
3047+
result.m_type = value_t::object;
3048+
result.m_value = value_t::object;
3049+
}
30423050
}
30433051

30443052
// read next token
@@ -3130,11 +3138,19 @@ class parser
31303138

31313139
case token_type::begin_array:
31323140
{
3133-
if (keep and (not callback or ((keep = callback(depth++, parse_event_t::array_start, result)))))
3141+
if (keep)
31343142
{
3135-
// explicitly set result to object to cope with []
3136-
result.m_type = value_t::array;
3137-
result.m_value = value_t::array;
3143+
if (callback)
3144+
{
3145+
keep = callback(depth++, parse_event_t::array_start, result);
3146+
}
3147+
3148+
if (not callback or keep)
3149+
{
3150+
// explicitly set result to array to cope with []
3151+
result.m_type = value_t::array;
3152+
result.m_value = value_t::array;
3153+
}
31383154
}
31393155

31403156
// read next token

test/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ set_target_properties(catch_main PROPERTIES
6666
)
6767
target_include_directories(catch_main PRIVATE "thirdparty/catch")
6868

69+
# https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake
70+
if(MSVC)
71+
# Force to always compile with W4
72+
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
73+
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
74+
else()
75+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
76+
endif()
77+
78+
# Disable warning C4389: '==': signed/unsigned mismatch
79+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4389")
80+
endif()
81+
6982
#############################################################################
7083
# one executable for each unit test file
7184
#############################################################################

test/src/unit-udt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void from_json(const BasicJsonType& j, country& c)
201201
{
202202
{u8"中华人民共和国", country::china},
203203
{"France", country::france},
204-
{"Российская Федерация", country::russia}
204+
{u8"Российская Федерация", country::russia}
205205
};
206206

207207
const auto it = m.find(str);

0 commit comments

Comments
 (0)