mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
parent
caae4dd0f8
commit
1b4d42ca2e
@ -63,6 +63,12 @@
|
|||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
|
||||||
|
#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
||||||
|
#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
|
||||||
|
|
||||||
namespace gsl
|
namespace gsl
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -846,4 +852,8 @@ as_writable_bytes(span<ElementType, Extent> s) noexcept
|
|||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif // __GNUC__ > 6
|
#endif // __GNUC__ > 6
|
||||||
|
|
||||||
|
#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // GSL_SPAN_H
|
#endif // GSL_SPAN_H
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
|
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
|
||||||
|
#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
||||||
|
#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
|
||||||
|
|
||||||
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
||||||
#define GSL_NODISCARD [[nodiscard]]
|
#define GSL_NODISCARD [[nodiscard]]
|
||||||
#else
|
#else
|
||||||
@ -154,4 +160,8 @@ constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size
|
|||||||
|
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // GSL_UTIL_H
|
#endif // GSL_UTIL_H
|
||||||
|
@ -123,11 +123,6 @@ if(MSVC) # MSVC or simulating MSVC
|
|||||||
if (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()
|
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()
|
else()
|
||||||
target_compile_options(gsl_tests_config INTERFACE
|
target_compile_options(gsl_tests_config INTERFACE
|
||||||
-fno-strict-aliasing
|
-fno-strict-aliasing
|
||||||
@ -191,6 +186,11 @@ else()
|
|||||||
>
|
>
|
||||||
)
|
)
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
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()
|
||||||
|
|
||||||
# for tests to find the gtest header
|
# for tests to find the gtest header
|
||||||
target_include_directories(gsl_tests_config SYSTEM INTERFACE
|
target_include_directories(gsl_tests_config SYSTEM INTERFACE
|
||||||
@ -262,11 +262,6 @@ if(MSVC) # MSVC or simulating MSVC
|
|||||||
if (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()
|
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()
|
else()
|
||||||
target_compile_options(gsl_tests_config_noexcept INTERFACE
|
target_compile_options(gsl_tests_config_noexcept INTERFACE
|
||||||
-fno-exceptions
|
-fno-exceptions
|
||||||
@ -307,6 +302,11 @@ else()
|
|||||||
>
|
>
|
||||||
)
|
)
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
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()
|
||||||
|
|
||||||
add_executable(gsl_noexcept_tests no_exception_ensure_tests.cpp)
|
add_executable(gsl_noexcept_tests no_exception_ensure_tests.cpp)
|
||||||
target_link_libraries(gsl_noexcept_tests
|
target_link_libraries(gsl_noexcept_tests
|
||||||
|
@ -333,7 +333,7 @@ TEST(span_test, from_array_constructor)
|
|||||||
EXPECT_TRUE(s.data() == std::addressof(arr2d[0]));
|
EXPECT_TRUE(s.data() == std::addressof(arr2d[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
int arr3d[2][3][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
int arr3d[2][3][2] = { { {1, 2}, {3, 4}, {5, 6} }, { {7, 8}, {9, 10}, {11, 12} } };
|
||||||
|
|
||||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user