[llvm] 3ae27fc - [MC][ELF] Fix gcc "enumeral and non-enumeral type in conditional expression" warning (NFC)

Yang Fan via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 22:59:36 PST 2021


Author: Yang Fan
Date: 2021-02-18T14:58:59+08:00
New Revision: 3ae27fca7ea584222bb93019d12bc79f2ada64f0

URL: https://github.com/llvm/llvm-project/commit/3ae27fca7ea584222bb93019d12bc79f2ada64f0
DIFF: https://github.com/llvm/llvm-project/commit/3ae27fca7ea584222bb93019d12bc79f2ada64f0.diff

LOG: [MC][ELF] Fix gcc "enumeral and non-enumeral type in conditional expression" warning (NFC)

GCC warning:
```
/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp: In member function ‘uint64_t {anonymous}::ELFWriter::writeObject(llvm::MCAssembler&, const llvm::MCAsmLayout&)’:
/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp:1137:38: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
 1137 |     write(uint32_t(Group->isComdat() ? ELF::GRP_COMDAT : 0));
      |                    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
```

Added: 
    

Modified: 
    llvm/lib/MC/ELFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index b99fce330c28..f6b015f7c560 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1134,7 +1134,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) {
 
     const MCSymbol *SignatureSymbol = Group->getGroup();
     assert(SignatureSymbol);
-    write(uint32_t(Group->isComdat() ? ELF::GRP_COMDAT : 0));
+    write(uint32_t(Group->isComdat() ? unsigned(ELF::GRP_COMDAT) : 0));
     for (const MCSectionELF *Member : GroupMembers[SignatureSymbol]) {
       uint32_t SecIndex = SectionIndexMap.lookup(Member);
       write(SecIndex);


        


More information about the llvm-commits mailing list