From eb52ac7a35b9dc64c710e56d5e9d422b4e53b6d6 Mon Sep 17 00:00:00 2001 From: Jonathan Gopel Date: Tue, 27 Oct 2020 21:46:38 -0600 Subject: [PATCH] :new: Enable -Wshadow in pedantic mode Problem: - All `-Wshadow` warnings are fixed but there is nothing stopping them from being reintroduced. Solution: - Fail pedantic builds on `-Wshadow` warnings. This allows CI to prevent reoccurrence of the warning. Notes: - Not enabling `-Wshadow` for gcc versions 4 or lower because the warning is much more aggressive there to the point that it's mostly just noise. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f21cf456..5889cee4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wdouble-promotion -Wtrampolines -Wzero-as-null-pointer-constant -Wuseless-cast - -Wvector-operation-performance -Wsized-deallocation) + -Wvector-operation-performance -Wsized-deallocation -Wshadow) endif () if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wshift-overflow=2 @@ -130,7 +130,7 @@ endif () if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(PEDANTIC_COMPILE_FLAGS -Wall -Wextra -pedantic -Wconversion -Wundef - -Wdeprecated -Wweak-vtables) + -Wdeprecated -Wweak-vtables -Wshadow) check_cxx_compiler_flag(-Wzero-as-null-pointer-constant HAS_NULLPTR_WARNING) if (HAS_NULLPTR_WARNING) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS}