mirror of
https://github.com/nlohmann/json.git
synced 2026-10-11 08:57:15 +00:00
Build files that suppress -Wnoexcept on their own
unit-udt.cpp suppresses GCC's -Wnoexcept around its include of the library just like unit-noexcept.cpp, so instead of listing the files, leave every file that suppresses the warning out of the batches. Move the helpers of unit-comparison.cpp into an anonymous namespace inside unit_comparison_detail, as clang-tidy's misc-use-internal-linkage wants internal linkage for them. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+18
-6
No files matched your search
+14
-5
@@ -416,11 +416,9 @@ function(json_test_add_unity_tests)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# files that must not be merged into a batch: unit-32bit.cpp is only built
|
# files that must not be merged into a batch: unit-32bit.cpp is only built
|
||||||
# for 32bit targets, unit-no-macro-leak.cpp checks that including the
|
# for 32bit targets, and unit-no-macro-leak.cpp checks that including the
|
||||||
# library defines no unprefixed macro, which any other file would disturb,
|
# library defines no unprefixed macro, which any other file would disturb
|
||||||
# and unit-noexcept.cpp suppresses GCC's -Wnoexcept around its include of
|
set(standalone_files unit-32bit.cpp unit-no-macro-leak.cpp)
|
||||||
# the library, which has no effect once another file included it first
|
|
||||||
set(standalone_files unit-32bit.cpp unit-no-macro-leak.cpp unit-noexcept.cpp)
|
|
||||||
|
|
||||||
set(harmless_macros "^(DOCTEST_.*|SKIP_TESTS_FOR_.*|JSON_TEST_DEPRECATED_FUNCTIONS_DELETED|JSON_TEST_STRICT_NUL_HANDLING_ENABLED|JSON_TEST_STRINGIZE)$")
|
set(harmless_macros "^(DOCTEST_.*|SKIP_TESTS_FOR_.*|JSON_TEST_DEPRECATED_FUNCTIONS_DELETED|JSON_TEST_STRICT_NUL_HANDLING_ENABLED|JSON_TEST_STRINGIZE)$")
|
||||||
|
|
||||||
@@ -446,6 +444,17 @@ function(json_test_add_unity_tests)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# files that suppress GCC's -Wnoexcept around their include of the
|
||||||
|
# library: the suppression has no effect once another file of the
|
||||||
|
# batch included the library first
|
||||||
|
if(batchable)
|
||||||
|
file(READ ${file} file_content)
|
||||||
|
string(FIND "${file_content}" "SUPPRESS_WARNING(\"-Wnoexcept\")" suppresses_noexcept)
|
||||||
|
if(NOT ${suppresses_noexcept} EQUAL -1)
|
||||||
|
set(batchable FALSE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(pool plain)
|
set(pool plain)
|
||||||
if(batchable)
|
if(batchable)
|
||||||
# collect the macros (un)defined before the library is included
|
# collect the macros (un)defined before the library is included
|
||||||
|
|||||||
@@ -544,6 +544,8 @@ TEST_CASE("lexicographical comparison operators")
|
|||||||
|
|
||||||
namespace unit_comparison_detail
|
namespace unit_comparison_detail
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
// orders keys ascending or descending, as chosen when a map is created
|
// orders keys ascending or descending, as chosen when a map is created
|
||||||
template<class Key>
|
template<class Key>
|
||||||
class directed_less
|
class directed_less
|
||||||
@@ -595,7 +597,7 @@ struct unordered_object_t : std::map<Key, Value, directed_less<Key>, Allocator>
|
|||||||
using unordered_json = nlohmann::json::with_object_t<unordered_object_t>;
|
using unordered_json = nlohmann::json::with_object_t<unordered_object_t>;
|
||||||
|
|
||||||
// the entries "0" to "9", enumerated in ascending or in descending order
|
// the entries "0" to "9", enumerated in ascending or in descending order
|
||||||
inline unordered_json make_unordered_object(const bool descending)
|
unordered_json make_unordered_object(const bool descending)
|
||||||
{
|
{
|
||||||
unordered_json j = unordered_json::object_t(directed_less<std::string>(descending));
|
unordered_json j = unordered_json::object_t(directed_less<std::string>(descending));
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
@@ -674,6 +676,7 @@ struct case_insensitive_less
|
|||||||
template<class Key, class Value, class /*Compare*/, class Allocator>
|
template<class Key, class Value, class /*Compare*/, class Allocator>
|
||||||
using case_insensitive_map = std::map<Key, Value, case_insensitive_less, Allocator>;
|
using case_insensitive_map = std::map<Key, Value, case_insensitive_less, Allocator>;
|
||||||
using ci_json = nlohmann::json::with_object_t<case_insensitive_map>;
|
using ci_json = nlohmann::json::with_object_t<case_insensitive_map>;
|
||||||
|
} // namespace
|
||||||
} // namespace unit_comparison_detail
|
} // namespace unit_comparison_detail
|
||||||
|
|
||||||
// using-declarations rather than a using-directive, as this file may be
|
// using-declarations rather than a using-directive, as this file may be
|
||||||
|
|||||||
Reference in new issue
Block a user