[llvm] [NFC] [CMake] Add -Wno-dangling-else for GCC built unittests (PR #112817)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 01:34:00 PDT 2024
================
@@ -14,6 +14,20 @@ function(add_llvm_target_unittest test_dir_name)
add_llvm_unittest(${test_dir_name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
endfunction()
+# gtest macros like EXPECT_TRUE are expanded to a single line
+# multi-statement code with if/else. eg:
+# if (...)
+# EXPECT_TURE(...)
+# will be expanded into something like:
+# if(...)
+# switch (0) case 0: default: if (...) ; else return;;
+# GCC may emit false positive dangling-else warnings for such code.
+# However, such warnings are actually against LLVM's style guide.
+# disable the warning for GCC so that one can enbable Werror.
----------------
jh7370 wrote:
`disable` -> `Disable`
`enbable` -> `enable`
I'd also do `Werror` -> `-Werror` to make it clear that this is an option.
https://github.com/llvm/llvm-project/pull/112817
More information about the llvm-commits
mailing list