From 2b04aaad945a5bf1d5feb419d0b53c421d83f394 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 2 Jul 2022 23:47:22 +0200 Subject: [PATCH] build: drop -Wsuggest #19177 Disable -Wsuggest compile flags by default. Although the flags are useful to see what the compiler thinks we can improve on, it adds a lot of noise to the build output. That makes it harder to spot actual issues that may be flagged. Closes https://github.com/neovim/neovim/issues/19160 --- CMakeLists.txt | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5175ba20dd..b996a8fb0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,6 +274,7 @@ int main(void) } " HAVE_BUILTIN_ADD_OVERFLOW) +option(ENABLE_COMPILER_SUGGESTIONS "Enable -Wsuggest compiler warnings" OFF) if(MSVC) # XXX: /W4 gives too many warnings. #3241 add_compile_options(/W3) @@ -292,25 +293,27 @@ else() add_compile_options(-Wimplicit-fallthrough) endif() - # Clang doesn't have -Wsuggest-attribute so check for each one. - check_c_compiler_flag(-Wsuggest-attribute=pure HAVE_WSUGGEST_ATTRIBUTE_PURE) - if(HAVE_WSUGGEST_ATTRIBUTE_PURE) - add_compile_options(-Wsuggest-attribute=pure) - endif() + if(ENABLE_COMPILER_SUGGESTIONS) + # Clang doesn't have -Wsuggest-attribute so check for each one. + check_c_compiler_flag(-Wsuggest-attribute=pure HAVE_WSUGGEST_ATTRIBUTE_PURE) + if(HAVE_WSUGGEST_ATTRIBUTE_PURE) + add_compile_options(-Wsuggest-attribute=pure) + endif() - check_c_compiler_flag(-Wsuggest-attribute=const HAVE_WSUGGEST_ATTRIBUTE_CONST) - if(HAVE_WSUGGEST_ATTRIBUTE_CONST) - add_compile_options(-Wsuggest-attribute=const) - endif() + check_c_compiler_flag(-Wsuggest-attribute=const HAVE_WSUGGEST_ATTRIBUTE_CONST) + if(HAVE_WSUGGEST_ATTRIBUTE_CONST) + add_compile_options(-Wsuggest-attribute=const) + endif() - check_c_compiler_flag(-Wsuggest-attribute=malloc HAVE_WSUGGEST_ATTRIBUTE_MALLOC) - if(HAVE_WSUGGEST_ATTRIBUTE_MALLOC) - add_compile_options(-Wsuggest-attribute=malloc) - endif() + check_c_compiler_flag(-Wsuggest-attribute=malloc HAVE_WSUGGEST_ATTRIBUTE_MALLOC) + if(HAVE_WSUGGEST_ATTRIBUTE_MALLOC) + add_compile_options(-Wsuggest-attribute=malloc) + endif() - check_c_compiler_flag(-Wsuggest-attribute=cold HAVE_WSUGGEST_ATTRIBUTE_COLD) - if(HAVE_WSUGGEST_ATTRIBUTE_COLD) - add_compile_options(-Wsuggest-attribute=cold) + check_c_compiler_flag(-Wsuggest-attribute=cold HAVE_WSUGGEST_ATTRIBUTE_COLD) + if(HAVE_WSUGGEST_ATTRIBUTE_COLD) + add_compile_options(-Wsuggest-attribute=cold) + endif() endif() # On FreeBSD 64 math.h uses unguarded C11 extension, which taints clang