Merge pull request #7481

430b758 Warnings: add warnings as errors: 'switch' & 'return-type' (mj-xmr)
This commit is contained in:
luigi1111 2021-06-10 11:19:11 -05:00
commit f85cab6750
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

View File

@ -805,6 +805,13 @@ else()
add_linker_flag_if_supported(-Wl,--high-entropy-va LD_SECURITY_FLAGS)
endif()
# Warnings, that when ignored are so severe, that they can segfault or even UB any application.
# Treat them as errors.
add_c_flag_if_supported( -Werror=switch C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-Werror=switch CXX_SECURITY_FLAGS)
add_c_flag_if_supported( -Werror=return-type C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-Werror=return-type CXX_SECURITY_FLAGS)
message(STATUS "Using C security hardening flags: ${C_SECURITY_FLAGS}")
message(STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}")
message(STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}")