Skip to content

Commit a4754da

Browse files
committed
USe -WShadow in clang builds
1 parent a2b620a commit a4754da

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ endif()
255255
# TODO(dbort): Fix these warnings and remove this flag.
256256
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
257257

258+
# Clang and GCC's semantics for -Wshadow differ in handling constructor args
259+
# with names that match a constructor field. We want Clang's semantics, as this
260+
# is enforced in certain existing use cases, which have caused reverts.
261+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
262+
list(APPEND _common_compile_options -Wshadow -Werror=shadow)
263+
endif()
264+
258265
# Let files say "include <executorch/path/to/header.h>".
259266
# TODO(#6475): This requires/assumes that the repo lives in a directory named
260267
# exactly `executorch`. Check the assumption first. Remove this check once we

0 commit comments

Comments
 (0)