forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: enable -Wshadow partially for in-tree code
This enables -Wshadow to warn about shadow variables on in tree code under arch/, boards/, drivers/, kernel/, lib/, soc/, and subsys/. Note that this does not enable it globally because out-of-tree modules will probably take some time to fix (or not at all depending on the project), and it would be great to avoid introduction of any new shadow variables in the meantime. Also note that this tries to be done in a minimally invasive way so it is easy to revert when we enable -Wshadow globally. Source files under modules/, samples/ and tests/ are currently excluded because there does not seem to be a trivial way to add -Wshadow there without going through all CMakeLists.txt to add the option (as there are 1000+ files to change). Signed-off-by: Daniel Leung <daniel.leung@intel.com>
- Loading branch information
1 parent
1f7e0de
commit e38fc6d
Showing
15 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
|
||
include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake) | ||
|
||
# Remove after testing that -Wshadow works | ||
set_compiler_property(PROPERTY warning_shadow_variables) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# FIXME: SHADOW_VARS: Remove this once we have enabled -Wshadow globally. | ||
# | ||
# Limit warning of shadow variables to in-tree SoC files for now. | ||
cmake_path(IS_PREFIX ZEPHYR_BASE "${SOC_DIR}" NORMALIZE _SOC_IS_IN_TREE) | ||
if(_SOC_IS_IN_TREE) | ||
add_compile_options($<TARGET_PROPERTY:compiler,warning_shadow_variables>) | ||
endif() | ||
unset(_SOC_IS_IN_TREE) | ||
|
||
if(EXISTS ${SOC_DIR}/${ARCH}/CMakeLists.txt) | ||
add_subdirectory(${SOC_DIR}/${ARCH} soc/${ARCH}) | ||
else() | ||
add_subdirectory(${SOC_DIR}/${ARCH}/${SOC_PATH} soc/${ARCH}/${SOC_PATH}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters