Skip to content

Commit 050e14d

Browse files
committed
Disable Wmissing-noreturn for test files
Adding unreachable to `FAIL` and `SKIP` made Clang become very good at figuring out that tests of `FAIL` and `SKIP` will never return and thus could be marked as [[noreturn]]. To avoid introducing lot of warning suppression noise into the test files, we just disable it instead.
1 parent 6097bd6 commit 050e14d

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ if(CATCH_BUILD_FUZZERS)
103103
endif()
104104

105105
if(CATCH_DEVELOPMENT_BUILD)
106-
add_warnings_to_targets("${CATCH_WARNING_TARGETS}")
106+
set(CATCH_ALL_TARGETS ${CATCH_IMPL_TARGETS} ${CATCH_TEST_TARGETS})
107+
add_warnings_to_targets("${CATCH_ALL_TARGETS}")
108+
# After we added the noreturn hint to FAIL and SKIP, Clang became
109+
# extremely good at diagnosing tests that test these macros as being
110+
# noreturn, but not marked as such. This made the warning useless for
111+
# our test files.
112+
add_cxx_flag_if_supported_to_targets("-Wno-missing-noreturn" "${CATCH_TEST_TARGETS}")
107113
endif()
108114

109115
# Only perform the installation steps when Catch is not being used as

examples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ foreach(name ${ALL_EXAMPLE_TARGETS})
5454
target_link_libraries(${name} Catch2WithMain)
5555
endforeach()
5656

57-
list(APPEND CATCH_WARNING_TARGETS ${ALL_EXAMPLE_TARGETS})
58-
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
57+
list(APPEND CATCH_TEST_TARGETS ${ALL_EXAMPLE_TARGETS})
58+
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ if(CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
451451
target_compile_features(Catch2_buildall_interface INTERFACE cxx_std_14)
452452
endif()
453453

454-
list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain)
455-
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
454+
list(APPEND CATCH_IMPL_TARGETS Catch2 Catch2WithMain)
455+
set(CATCH_IMPL_TARGETS ${CATCH_IMPL_TARGETS} PARENT_SCOPE)
456456

457457
# We still do not support building dynamic library with hidden visibility
458458
# so we want to check & warn users if they do this. However, we won't abort

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,5 +662,5 @@ foreach(reporterName # "Automake" - the simple .trs format does not support any
662662
)
663663
endforeach()
664664

665-
list(APPEND CATCH_WARNING_TARGETS SelfTest)
666-
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
665+
list(APPEND CATCH_TEST_TARGETS SelfTest)
666+
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)

tests/ExtraTests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ if(MSVC)
215215
add_executable(WindowsHeader ${TESTS_DIR}/X90-WindowsHeaderInclusion.cpp)
216216
target_link_libraries(WindowsHeader Catch2WithMain)
217217
add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact)
218-
list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES} WindowsHeader)
218+
list(APPEND CATCH_TEST_TARGETS ${EXTRA_TEST_BINARIES} WindowsHeader)
219219
endif()
220220

221221
add_executable(PartialTestCaseEvents ${TESTS_DIR}/X21-PartialTestCaseEvents.cpp)
@@ -502,8 +502,8 @@ set(EXTRA_TEST_BINARIES
502502
# Notice that we are modifying EXTRA_TEST_BINARIES destructively, do not
503503
# use it after this point!
504504
list(FILTER EXTRA_TEST_BINARIES EXCLUDE REGEX "DisabledExceptions.*")
505-
list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES})
506-
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
505+
list(APPEND CATCH_TEST_TARGETS ${EXTRA_TEST_BINARIES})
506+
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)
507507

508508
# This sets up a one-off executable that compiles against the amalgamated
509509
# files, and then runs it for a super simple check that the amalgamated

0 commit comments

Comments
 (0)