Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
8cae9d7c
J
json
项目概览
畅游知识海洋
/
json
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
json
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
8cae9d7c
编写于
8月 17, 2021
作者:
N
Niels Lohmann
提交者:
GitHub
8月 17, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Overwork warning flags (#2936)
*
⚗
update warning flags
上级
f1e63a83
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
123 addition
and
38 deletion
+123
-38
cmake/ci.cmake
cmake/ci.cmake
+26
-5
doc/mkdocs/docs/api/basic_json/binary_t.md
doc/mkdocs/docs/api/basic_json/binary_t.md
+1
-1
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
+1
-1
include/nlohmann/byte_container_with_subtype.hpp
include/nlohmann/byte_container_with_subtype.hpp
+2
-2
include/nlohmann/detail/macro_scope.hpp
include/nlohmann/detail/macro_scope.hpp
+3
-2
include/nlohmann/detail/macro_unscope.hpp
include/nlohmann/detail/macro_unscope.hpp
+2
-2
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+7
-6
test/src/unit-assert_macro.cpp
test/src/unit-assert_macro.cpp
+9
-5
test/src/unit-conversions.cpp
test/src/unit-conversions.cpp
+6
-0
test/src/unit-disabled_exceptions.cpp
test/src/unit-disabled_exceptions.cpp
+6
-0
test/src/unit-items.cpp
test/src/unit-items.cpp
+9
-0
test/src/unit-json_pointer.cpp
test/src/unit-json_pointer.cpp
+5
-7
test/src/unit-noexcept.cpp
test/src/unit-noexcept.cpp
+6
-0
test/src/unit-readme.cpp
test/src/unit-readme.cpp
+4
-7
test/src/unit-regression2.cpp
test/src/unit-regression2.cpp
+6
-0
test/src/unit-udt.cpp
test/src/unit-udt.cpp
+6
-0
test/src/unit-unicode2.cpp
test/src/unit-unicode2.cpp
+6
-0
test/src/unit-unicode3.cpp
test/src/unit-unicode3.cpp
+6
-0
test/src/unit-unicode4.cpp
test/src/unit-unicode4.cpp
+6
-0
test/src/unit-unicode5.cpp
test/src/unit-unicode5.cpp
+6
-0
未找到文件。
cmake/ci.cmake
浏览文件 @
8cae9d7c
...
...
@@ -88,21 +88,36 @@ file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
# Thorough check with recent compilers
###############################################################################
# Ignored Clang warnings:
# -Wno-c++98-compat The library targets C++11.
# -Wno-c++98-compat-pedantic The library targets C++11.
# -Wno-deprecated-declarations The library contains annotations for deprecated functions.
# -Wno-extra-semi-stmt The library uses std::assert which triggers this warning.
# -Wno-padded We do not care about padding warnings.
# -Wno-covered-switch-default All switches list all cases and a default case.
# -Wno-weak-vtables The library is header-only.
set
(
CLANG_CXXFLAGS
"-std=c++11 \
-Werror \
-Weverything \
-Wno-c++98-compat \
-Wno-c++98-compat-pedantic \
-Wno-deprecated-declarations \
-Wno-documentation-unknown-command \
-Wno-exit-time-destructors \
-Wno-extra-semi-stmt \
-Wno-padded \
-Wno-range-loop-analysis \
-Wno-covered-switch-default \
-Wno-weak-vtables \
"
)
# Ignored GCC warnings:
# -Wno-abi-tag We do not care about ABI tags.
# -Wno-aggregate-return The library uses aggregate returns.
# -Wno-long-long The library uses the long long type to interface with system functions.
# -Wno-namespaces The library uses namespaces.
# -Wno-padded We do not care about padding warnings.
# -Wno-system-headers We do not care about warnings in system headers.
# -Wno-templates The library uses templates.
set
(
GCC_CXXFLAGS
"-std=c++11 \
-pedantic \
-Werror \
...
...
@@ -203,10 +218,16 @@ set(GCC_CXXFLAGS "-std=c++11 \
-Wextra-semi \
-Wfloat-conversion \
-Wfloat-equal \
-Wformat-contains-nul \
-Wformat-diag \
-Wformat-extra-args \
-Wformat-nonliteral \
-Wformat-overflow=2 \
-Wformat-security \
-Wformat-signedness \
-Wformat-truncation=2 \
-Wformat-y2k \
-Wformat-zero-length \
-Wformat=2 \
-Wframe-address \
-Wfree-nonheap-object \
...
...
@@ -249,7 +270,7 @@ set(GCC_CXXFLAGS "-std=c++11 \
-Wmultistatement-macros \
-Wno-namespaces \
-Wnarrowing \
-Wno
-no
except \
-Wnoexcept \
-Wnoexcept-type \
-Wnon-template-friend \
-Wnon-virtual-dtor \
...
...
@@ -277,7 +298,7 @@ set(GCC_CXXFLAGS "-std=c++11 \
-Wpragmas \
-Wprio-ctor-dtor \
-Wpsabi \
-W
no-
range-loop-construct \
-Wrange-loop-construct \
-Wredundant-decls \
-Wredundant-move \
-Wredundant-tags \
...
...
doc/mkdocs/docs/api/basic_json/binary_t.md
浏览文件 @
8cae9d7c
...
...
@@ -64,4 +64,4 @@ type `#!cpp binary_t*` must be dereferenced.
## Version history
-
Added in version 3.8.0. Changed type of subtype to
`std::uint64_t`
in version 3.
9.2
.
-
Added in version 3.8.0. Changed type of subtype to
`std::uint64_t`
in version 3.
10.0
.
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
浏览文件 @
8cae9d7c
...
...
@@ -22,4 +22,4 @@ store
## Version history
-
Added in version 3.9.0. Added value
`store`
in 3.
9.2
.
-
Added in version 3.9.0. Added value
`store`
in 3.
10.0
.
include/nlohmann/byte_container_with_subtype.hpp
浏览文件 @
8cae9d7c
...
...
@@ -18,7 +18,7 @@ order to override the binary type.
@tparam BinaryType container to store bytes (`std::vector<std::uint8_t>` by
default)
@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.
9.2
.
@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.
10.0
.
*/
template
<
typename
BinaryType
>
class
byte_container_with_subtype
:
public
BinaryType
...
...
@@ -108,7 +108,7 @@ class byte_container_with_subtype : public BinaryType
subtype
@since version 3.8.0; fixed return value to properly return
subtype_type(-1) as documented in version 3.
9.2
subtype_type(-1) as documented in version 3.
10.0
*/
constexpr
subtype_type
subtype
()
const
noexcept
{
...
...
include/nlohmann/detail/macro_scope.hpp
浏览文件 @
8cae9d7c
...
...
@@ -38,8 +38,9 @@
// disable documentation warnings on clang
#if defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
#endif
// allow to disable exceptions
...
...
include/nlohmann/detail/macro_unscope.hpp
浏览文件 @
8cae9d7c
#pragma once
// restore
GCC/
clang diagnostic settings
// restore clang diagnostic settings
#if defined(__clang__)
#pragma
GCC
diagnostic pop
#pragma
clang
diagnostic pop
#endif
// clean up
...
...
single_include/nlohmann/json.hpp
浏览文件 @
8cae9d7c
...
...
@@ -2250,8 +2250,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP
// disable documentation warnings on clang
#if defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
#endif
// allow to disable exceptions
...
...
@@ -5003,7 +5004,7 @@ order to override the binary type.
@tparam BinaryType container to store bytes (`std::vector<std::uint8_t>` by
default)
@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.
9.2
.
@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.
10.0
.
*/
template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
...
...
@@ -5093,7 +5094,7 @@ class byte_container_with_subtype : public BinaryType
subtype
@since version 3.8.0; fixed return value to properly return
subtype_type(-1) as documented in version 3.
9.2
subtype_type(-1) as documented in version 3.
10.0
*/
constexpr subtype_type subtype() const noexcept
{
...
...
@@ -26423,9 +26424,9 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std
// #include <nlohmann/detail/macro_unscope.hpp>
// restore
GCC/
clang diagnostic settings
// restore clang diagnostic settings
#if defined(__clang__)
#pragma
GCC
diagnostic pop
#pragma
clang
diagnostic pop
#endif
// clean up
...
...
test/src/unit-assert_macro.cpp
浏览文件 @
8cae9d7c
...
...
@@ -27,13 +27,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// avoid warning when assert does not abort
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wstrict-overflow"
#endif
#include "doctest_compatibility.h"
// avoid warning when assert does not abort
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING
(
"-Wstrict-overflow"
)
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wstrict-overflow"
)
/// global variable to record side effect of assert calls
static
int
assert_counter
;
...
...
@@ -63,3 +64,6 @@ TEST_CASE("JSON_ASSERT(x)")
}
}
#endif
DOCTEST_GCC_SUPPRESS_WARNING_POP
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-conversions.cpp
浏览文件 @
8cae9d7c
...
...
@@ -48,6 +48,10 @@ using nlohmann::json;
#define JSON_HAS_CPP_14
#endif
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wexit-time-destructors"
)
TEST_CASE
(
"value conversion"
)
{
SECTION
(
"get an object (explicit)"
)
...
...
@@ -1712,3 +1716,5 @@ TEST_CASE("JSON to enum mapping")
#ifdef JSON_HAS_CPP_14
#undef JSON_HAS_CPP_14
#endif
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-disabled_exceptions.cpp
浏览文件 @
8cae9d7c
...
...
@@ -29,6 +29,10 @@ SOFTWARE.
#include "doctest_compatibility.h"
// disable -Wnoexcept as exceptions are switched off for this test suite
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING
(
"-Wnoexcept"
)
#include <nlohmann/json.hpp>
using
json
=
nlohmann
::
json
;
...
...
@@ -64,3 +68,5 @@ TEST_CASE("Tests with disabled exceptions")
delete
sax_no_exception
::
error_string
;
// NOLINT(cppcoreguidelines-owning-memory)
}
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
test/src/unit-items.cpp
浏览文件 @
8cae9d7c
...
...
@@ -39,6 +39,12 @@ using nlohmann::json;
#define JSON_HAS_CPP_14
#endif
// This test suite uses range for loops where values are copied. This is inefficient in usual code, but required to achieve 100% coverage.
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING
(
"-Wrange-loop-construct"
)
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wrange-loop-construct"
)
TEST_CASE
(
"iterator_wrapper"
)
{
SECTION
(
"object"
)
...
...
@@ -1456,3 +1462,6 @@ TEST_CASE("items()")
#ifdef JSON_HAS_CPP_14
#undef JSON_HAS_CPP_14
#endif
DOCTEST_GCC_SUPPRESS_WARNING_POP
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-json_pointer.cpp
浏览文件 @
8cae9d7c
...
...
@@ -358,10 +358,10 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_WITH
(
j_const
[
jp
]
==
1
,
throw_msg
.
c_str
());
}
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4127) // on some machines, the check below is not constant
#endif
// on some machines, the check below is not constant
DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
DOCTEST_MSVC_SUPPRESS_WARNING
(
4127
)
if
(
sizeof
(
typename
json
::
size_type
)
<
sizeof
(
unsigned
long
long
))
{
auto
size_type_max_uul
=
static_cast
<
unsigned
long
long
>
((
std
::
numeric_limits
<
json
::
size_type
>::
max
)());
...
...
@@ -375,9 +375,7 @@ TEST_CASE("JSON pointers")
CHECK_THROWS_WITH
(
j_const
[
jp
]
==
1
,
throw_msg
.
c_str
());
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
DOCTEST_MSVC_SUPPRESS_WARNING_POP
CHECK_THROWS_AS
(
j
.
at
(
"/one"
_json_pointer
)
=
1
,
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
j
.
at
(
"/one"
_json_pointer
)
=
1
,
...
...
test/src/unit-noexcept.cpp
浏览文件 @
8cae9d7c
...
...
@@ -29,6 +29,10 @@ SOFTWARE.
#include "doctest_compatibility.h"
// disable -Wnoexcept due to struct pod_bis
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING
(
"-Wnoexcept"
)
#include <nlohmann/json.hpp>
using
nlohmann
::
json
;
...
...
@@ -95,3 +99,5 @@ TEST_CASE("runtime checks")
from_json
(
j2
,
pod_bis
());
}
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
test/src/unit-readme.cpp
浏览文件 @
8cae9d7c
...
...
@@ -42,10 +42,9 @@ using nlohmann::json;
#include <sstream>
#include <iomanip>
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4189) // local variable is initialized but not referenced
#endif
// local variable is initialized but not referenced
DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
DOCTEST_MSVC_SUPPRESS_WARNING
(
4189
)
TEST_CASE
(
"README"
*
doctest
::
skip
())
{
...
...
@@ -321,6 +320,4 @@ TEST_CASE("README" * doctest::skip())
}
}
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
DOCTEST_MSVC_SUPPRESS_WARNING_POP
test/src/unit-regression2.cpp
浏览文件 @
8cae9d7c
...
...
@@ -53,6 +53,10 @@ using nlohmann::json;
#include <span>
#endif
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wexit-time-destructors"
)
/////////////////////////////////////////////////////////////////////
// for #1021
/////////////////////////////////////////////////////////////////////
...
...
@@ -656,3 +660,5 @@ TEST_CASE("regression tests 2")
static_assert
(
std
::
is_copy_assignable
<
nlohmann
::
ordered_json
>::
value
,
""
);
}
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-udt.cpp
浏览文件 @
8cae9d7c
...
...
@@ -29,6 +29,10 @@ SOFTWARE.
#include "doctest_compatibility.h"
// disable -Wnoexcept due to class Evil
DOCTEST_GCC_SUPPRESS_WARNING_PUSH
DOCTEST_GCC_SUPPRESS_WARNING
(
"-Wnoexcept"
)
#include <nlohmann/json.hpp>
using
nlohmann
::
json
;
...
...
@@ -845,3 +849,5 @@ TEST_CASE("Issue #1237")
struct
non_convertible_type
{};
static_assert
(
!
std
::
is_convertible
<
json
,
non_convertible_type
>::
value
,
""
);
}
DOCTEST_GCC_SUPPRESS_WARNING_POP
test/src/unit-unicode2.cpp
浏览文件 @
8cae9d7c
...
...
@@ -41,6 +41,10 @@ using nlohmann::json;
#include <iomanip>
#include <test_data.hpp>
// this test suite uses static variables with non-trivial destructors
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wexit-time-destructors"
)
namespace
{
extern
size_t
calls
;
...
...
@@ -623,3 +627,5 @@ TEST_CASE("Unicode (2/5)" * doctest::skip())
}
}
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-unicode3.cpp
浏览文件 @
8cae9d7c
...
...
@@ -41,6 +41,10 @@ using nlohmann::json;
#include <iomanip>
#include <test_data.hpp>
// this test suite uses static variables with non-trivial destructors
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wexit-time-destructors"
)
namespace
{
extern
size_t
calls
;
...
...
@@ -337,3 +341,5 @@ TEST_CASE("Unicode (3/5)" * doctest::skip())
}
}
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-unicode4.cpp
浏览文件 @
8cae9d7c
...
...
@@ -41,6 +41,10 @@ using nlohmann::json;
#include <iomanip>
#include <test_data.hpp>
// this test suite uses static variables with non-trivial destructors
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wexit-time-destructors"
)
namespace
{
extern
size_t
calls
;
...
...
@@ -337,3 +341,5 @@ TEST_CASE("Unicode (4/5)" * doctest::skip())
}
}
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
test/src/unit-unicode5.cpp
浏览文件 @
8cae9d7c
...
...
@@ -41,6 +41,10 @@ using nlohmann::json;
#include <iomanip>
#include <test_data.hpp>
// this test suite uses static variables with non-trivial destructors
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING
(
"-Wexit-time-destructors"
)
namespace
{
extern
size_t
calls
;
...
...
@@ -337,3 +341,5 @@ TEST_CASE("Unicode (5/5)" * doctest::skip())
}
}
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录