Skip to content

Commit 898320d

Browse files
authored
[cmake] Disable all -Wuninitialized warnings on GCC older than 12. (#76251)
As discussed in #75183, avoids dealing with GCC false positives.
1 parent 75073e0 commit 898320d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,13 @@ set(USE_NO_UNINITIALIZED 0)
431431
# Disable gcc's potentially uninitialized use analysis as it presents lots of
432432
# false positives.
433433
if (CMAKE_COMPILER_IS_GNUCXX)
434-
check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED)
435-
if (HAS_MAYBE_UNINITIALIZED)
436-
set(USE_NO_MAYBE_UNINITIALIZED 1)
437-
else()
438-
# Only recent versions of gcc make the distinction between -Wuninitialized
439-
# and -Wmaybe-uninitialized. If -Wmaybe-uninitialized isn't supported, just
440-
# turn off all uninitialized use warnings.
434+
# Disable all -Wuninitialized warning for old GCC versions.
435+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
441436
check_cxx_compiler_flag("-Wuninitialized" HAS_UNINITIALIZED)
442437
set(USE_NO_UNINITIALIZED ${HAS_UNINITIALIZED})
438+
else()
439+
check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED)
440+
set(USE_NO_MAYBE_UNINITIALIZED ${HAS_MAYBE_UNINITIALIZED})
443441
endif()
444442
endif()
445443

0 commit comments

Comments
 (0)