You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[NFC] [CMake] Add -Wno-dangling-else for GCC built unittests (#112817)
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on.
Built by GCC 11.
Fix warnings:
llvm/unittests/ProfileData/CoverageMappingTest.cpp: In member function
‘virtual void
{anonymous}::CoverageMappingTest_TVIdxBuilder_Test::TestBody()’:
llvm/unittests/ProfileData/CoverageMappingTest.cpp:1116:10: error:
suggest explicit braces to avoid ambiguous ‘else’
[-Werror=dangling-else]
1116 | if (Node.NextIDs[C] < 0)
The problem here is because these macros, eg: EXPECT_TRUE are expanded
to a single line multi-statement code with if/else, which is indeed
ambiguous after pre-processing. a simple example would be like:
https://godbolt.org/z/4zjn56qrP
if(x)
switch (0) case 0: default: if (...) ; else return;;
Given that omit braces in such cases is part of LLVM's style guide, and
it is hard to add braces in gtest just for GCC's warning, add
-Wno-dangling-else for GCC instead.
0 commit comments