mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Suppress some noisy / buggy warnings (#1136)
Two warnings were being emitted in the MSVC+LLVM tests. The warning `-Wunsafe-buffer-usage` is initially introduced in some capacity here https://reviews.llvm.org/D137346 pointing to documentation at https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734. The warning is a stylistic checker whose goal is to "emit a warning every time an unsafe operation is performed on a raw pointer". This type of programming model is not useful for library implementations of types such as `span`, where direct manipulation of raw pointers is inevitable, so disable the warning altogether. There is also a false-positive warning https://github.com/llvm/llvm-project/issues/65689 that I've disabled inline.
This commit is contained in:
parent
9695da9b38
commit
2940006b5c
@ -777,8 +777,15 @@ span(const Container&) -> span<Element>;
|
||||
#endif // ( defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L) )
|
||||
|
||||
#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND)
|
||||
#if defined(__clang__) && defined(_MSC_VER) && defined(__cplusplus) && (__cplusplus < 201703L)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated" // Bug in clang-cl.exe which raises a C++17 -Wdeprecated warning about this static constexpr workaround in C++14 mode.
|
||||
#endif // defined(__clang__) && defined(_MSC_VER) && defined(__cplusplus) && (__cplusplus < 201703L)
|
||||
template <class ElementType, std::size_t Extent>
|
||||
constexpr const typename span<ElementType, Extent>::size_type span<ElementType, Extent>::extent;
|
||||
#if defined(__clang__) && defined(_MSC_VER) && defined(__cplusplus) && (__cplusplus < 201703L)
|
||||
#pragma clang diagnostic pop
|
||||
#endif // defined(__clang__) && defined(_MSC_VER) && defined(__cplusplus) && (__cplusplus < 201703L)
|
||||
#endif
|
||||
|
||||
namespace details
|
||||
|
@ -121,7 +121,12 @@ if(MSVC) # MSVC or simulating MSVC
|
||||
)
|
||||
check_cxx_compiler_flag("-Wno-reserved-identifier" WARN_RESERVED_ID)
|
||||
if (WARN_RESERVED_ID)
|
||||
target_compile_options(gsl_tests_config INTERFACE "-Wno-reserved-identifier")
|
||||
target_compile_options(gsl_tests_config INTERFACE "-Wno-reserved-identifier")
|
||||
endif()
|
||||
check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
|
||||
if (WARN_UNSAFE_BUFFER)
|
||||
# This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer"
|
||||
target_compile_options(gsl_tests_config INTERFACE "-Wno-unsafe-buffer-usage")
|
||||
endif()
|
||||
else()
|
||||
target_compile_options(gsl_tests_config INTERFACE
|
||||
@ -255,7 +260,12 @@ if(MSVC) # MSVC or simulating MSVC
|
||||
)
|
||||
check_cxx_compiler_flag("-Wno-reserved-identifier" WARN_RESERVED_ID)
|
||||
if (WARN_RESERVED_ID)
|
||||
target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-reserved-identifier")
|
||||
target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-reserved-identifier")
|
||||
endif()
|
||||
check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
|
||||
if (WARN_UNSAFE_BUFFER)
|
||||
# This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer"
|
||||
target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-unsafe-buffer-usage")
|
||||
endif()
|
||||
else()
|
||||
target_compile_options(gsl_tests_config_noexcept INTERFACE
|
||||
|
Loading…
Reference in New Issue
Block a user