From 29ce08c820c245c2b575a127fd50b4f4564bfc6f Mon Sep 17 00:00:00 2001 From: Nicholas Guriev Date: Thu, 24 Sep 2026 11:11:56 +0300 Subject: [PATCH] Check positive warning options GCC or other compatible compiler always accepts unknown -Wno-* flags; thus, check_cxx_compiler_flag() never fails on them and is meaningless. There are two options to fix this: either remove the checks altogether, or check for positive -W flags and set the desired -Wno-* ones. This commit chooses the second approach. --- tests/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 82e84cb0..8accea98 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -124,7 +124,7 @@ if(MSVC) # MSVC or simulating MSVC > > ) - check_cxx_compiler_flag("-Wno-reserved-identifier" WARN_RESERVED_ID) + check_cxx_compiler_flag("-Wreserved-identifier" WARN_RESERVED_ID) if (WARN_RESERVED_ID) target_compile_options(gsl_tests_config INTERFACE "-Wno-reserved-identifier") endif() @@ -193,7 +193,7 @@ else() > ) endif(MSVC) -check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) +check_cxx_compiler_flag("-Wunsafe-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") @@ -260,7 +260,7 @@ if(MSVC) # MSVC or simulating MSVC > > ) - check_cxx_compiler_flag("-Wno-reserved-identifier" WARN_RESERVED_ID) + check_cxx_compiler_flag("-Wreserved-identifier" WARN_RESERVED_ID) if (WARN_RESERVED_ID) target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-reserved-identifier") endif() @@ -305,7 +305,7 @@ else() > ) endif(MSVC) -check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) +check_cxx_compiler_flag("-Wunsafe-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")