CMake: use -Wshadow warning for C source

C source now builds without shadowing, enable with GCC by default.
This commit is contained in:
Campbell Barton 2015-11-23 15:45:52 +11:00
parent 64ab452131
commit 4fe413a419
2 changed files with 12 additions and 0 deletions

View File

@ -2602,6 +2602,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
endif()
# versions before gcc4.8 include global name-space.
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_SHADOW -Wshadow)
endif()
# disable because it gives warnings for printf() & friends.
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)

View File

@ -23,6 +23,13 @@
#
# ***** END GPL LICENSE BLOCK *****
if(CMAKE_COMPILER_IS_GNUCC)
remove_cc_flag(
"-Wshadow"
"-Werror=shadow"
)
endif()
set(INC
.
)