[all-commits] [llvm/llvm-project] d72e71: [NFC] [CMake] Add -Wno-dangling-else for GCC built...
Jinsong Ji via All-commits
all-commits at lists.llvm.org
Sat Oct 26 14:40:32 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d72e711e864dad7e3a434d66f3febad2b1596335
https://github.com/llvm/llvm-project/commit/d72e711e864dad7e3a434d66f3febad2b1596335
Author: Jinsong Ji <jinsong.ji at intel.com>
Date: 2024-10-26 (Sat, 26 Oct 2024)
Changed paths:
M llvm/unittests/CMakeLists.txt
Log Message:
-----------
[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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list