Skip to content

Commit

Permalink
[CMake] Disable -Warray-bounds on GCC 11-13+
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Sep 8, 2023
1 parent 970d03b commit 42a8d6b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ macro(CONFIGURE_WZ_COMPILER_WARNINGS)

# -Wshadow (GCC 3.4+, Clang 3.2+)
# NOTE: -Wshadow on GCC is currently too noisy, but Clang 3.9+ is much more selective
if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9))
if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.9))
check_compiler_flags_output("-Werror -Wshadow -Wno-error=cpp" COMPILER_TYPE C OUTPUT_FLAGS "-Wshadow" OUTPUT_VARIABLE _supported_c_compiler_flags APPEND)

# -Wno-shadow-field-in-constructor (Clang 3.9+)
Expand Down Expand Up @@ -646,6 +646,14 @@ macro(CONFIGURE_WZ_COMPILER_WARNINGS)
check_compiler_flags_output("-Werror -Wformat-truncation -Wno-error=cpp" COMPILER_TYPE C OUTPUT_FLAGS "-Wno-format-truncation" OUTPUT_VARIABLE _supported_c_compiler_flags APPEND)
check_compiler_flags_output("-Werror -Wformat-truncation -Wno-error=cpp" COMPILER_TYPE CXX OUTPUT_FLAGS "-Wno-format-truncation" OUTPUT_VARIABLE _supported_cxx_compiler_flags APPEND)

# Disable -Warray-bounds on GCC 11-13+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 11))
check_compiler_flags_output("-Werror -Wno-array-bounds -Wno-error=cpp" COMPILER_TYPE C OUTPUT_FLAGS "-Wno-array-bounds" OUTPUT_VARIABLE _supported_c_compiler_flags APPEND)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11))
check_compiler_flags_output("-Werror -Wno-array-bounds -Wno-error=cpp" COMPILER_TYPE CXX OUTPUT_FLAGS "-Wno-array-bounds" OUTPUT_VARIABLE _supported_cxx_compiler_flags APPEND)
endif()

message( STATUS "Supported C compiler_flags=${_supported_c_compiler_flags}" )
message( STATUS "Supported CXX compiler_flags=${_supported_cxx_compiler_flags}" )

Expand Down

0 comments on commit 42a8d6b

Please sign in to comment.