aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-02-15 08:51:40 +0100
committerGitHub <noreply@github.com>2023-02-15 08:51:40 +0100
commit8307ed3a194d0c0420feb0b3e5c2f6919095415f (patch)
tree45336093fa5ab863db3403467991812d52637e8c
parent1539f713639eb1c661da9f9003fd58bf4cbbc615 (diff)
downloadrneovim-8307ed3a194d0c0420feb0b3e5c2f6919095415f.tar.gz
rneovim-8307ed3a194d0c0420feb0b3e5c2f6919095415f.tar.bz2
rneovim-8307ed3a194d0c0420feb0b3e5c2f6919095415f.zip
revert: "build: remove ENABLE_COMPILER_SUGGESTIONS option" (#22265)
This reverts commit 1d6bb0892b58e5a4183e74c0fbd2dc20204e33a4. See: https://github.com/neovim/neovim/pull/22249#issuecomment-1430548550
-rwxr-xr-xsrc/nvim/CMakeLists.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 22cbec0d06..a193af6d51 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -105,6 +105,30 @@ if(HAVE_WIMPLICIT_FALLTHROUGH_FLAG)
target_compile_options(main_lib INTERFACE -Wimplicit-fallthrough)
endif()
+option(ENABLE_COMPILER_SUGGESTIONS "Enable -Wsuggest compiler warnings" OFF)
+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)
+ target_compile_options(main_lib INTERFACE -Wsuggest-attribute=pure)
+ endif()
+
+ check_c_compiler_flag(-Wsuggest-attribute=const HAVE_WSUGGEST_ATTRIBUTE_CONST)
+ if(HAVE_WSUGGEST_ATTRIBUTE_CONST)
+ target_compile_options(main_lib INTERFACE -Wsuggest-attribute=const)
+ endif()
+
+ check_c_compiler_flag(-Wsuggest-attribute=malloc HAVE_WSUGGEST_ATTRIBUTE_MALLOC)
+ if(HAVE_WSUGGEST_ATTRIBUTE_MALLOC)
+ target_compile_options(main_lib INTERFACE -Wsuggest-attribute=malloc)
+ endif()
+
+ check_c_compiler_flag(-Wsuggest-attribute=cold HAVE_WSUGGEST_ATTRIBUTE_COLD)
+ if(HAVE_WSUGGEST_ATTRIBUTE_COLD)
+ target_compile_options(main_lib INTERFACE -Wsuggest-attribute=cold)
+ endif()
+endif()
+
if(MINGW)
# Use POSIX compatible stdio in Mingw
target_compile_definitions(main_lib INTERFACE __USE_MINGW_ANSI_STDIO)