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:
Niels Lohmann committed 2026-10-10 07:45:41 +02:00
1 parent 169f1fcb2d
commit 80fd9c0fb4
2 files changed
+18 -6

No files matched your search

+14 -5
View File
@@ -416,11 +416,9 @@ function(json_test_add_unity_tests)
endforeach()
# 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
# library defines no unprefixed macro, which any other file would disturb,
# and unit-noexcept.cpp suppresses GCC's -Wnoexcept around its include of
# 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)
# for 32bit targets, and unit-no-macro-leak.cpp checks that including the
# library defines no unprefixed macro, which any other file would disturb
set(standalone_files unit-32bit.cpp unit-no-macro-leak.cpp)
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()
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)
if(batchable)
# collect the macros (un)defined before the library is included