[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)
Mikael Holmén via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 28 04:55:26 PDT 2025
mikaelholmen wrote:
> > The FPEvalMethod warning should have been addressed in #136515, by making the relevant bitfields large enough to actually store the enum, are you still seeing these failures?
>
> Yes, I'm still seeing this warning. The earlier quoted warning was maybe from bisecting it; on the very latest git main I'm getting this:
>
> ```
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:350:1: warning: assigning value of preferred signed enum type 'FPEvalMethodKind' to unsigned bit-field 'FPEvalMethod'; negative enumerators of enum 'FPEvalMethodKind' will be converted to positive values [-Wpreferred-type-bitfield-enum-conversion]
> 350 | BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic")
> | ^
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:67:6: note: expanded from macro 'BENIGN_ENUM_LANGOPT'
> 67 | COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
> | ^
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:62:6: note: expanded from macro 'COMPATIBLE_ENUM_LANGOPT'
> 62 | ENUM_LANGOPT(Name, Type, Bits, Default, Description)
> | ^
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.h:661:10: note: expanded from macro 'ENUM_LANGOPT'
> 661 | Name = static_cast<unsigned>(Value); \
> | ^
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:350:1: note: consider making the bit-field type signed
> 350 | BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic")
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:67:6: note: expanded from macro 'BENIGN_ENUM_LANGOPT'
> 67 | COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:62:6: note: expanded from macro 'COMPATIBLE_ENUM_LANGOPT'
> 62 | ENUM_LANGOPT(Name, Type, Bits, Default, Description)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.h:501:3: note: expanded from macro 'ENUM_LANGOPT'
> 501 | unsigned Name : Bits;
> | ^~~~~~~~
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:350:1: note: preferred type for bit-field 'FPEvalMethodKind' specified here
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:67:6: note: expanded from macro 'BENIGN_ENUM_LANGOPT'
> 67 | COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
> | ^
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.def:62:6: note: expanded from macro 'COMPATIBLE_ENUM_LANGOPT'
> 62 | ENUM_LANGOPT(Name, Type, Bits, Default, Description)
> | ^
> /home/martin/code/llvm-project/clang/include/clang/Basic/LangOptions.h:500:3: note: expanded from macro 'ENUM_LANGOPT'
> 500 | LLVM_PREFERRED_TYPE(Type) \
> | ^
> /home/martin/code/llvm-project/llvm/include/llvm/Support/Compiler.h:708:47: note: expanded from macro 'LLVM_PREFERRED_TYPE'
> 708 | #define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T)))
> | ^
> 1 warning generated.
> ```
I still see this on downstream build bots. How is the fix proceeding?
https://github.com/llvm/llvm-project/pull/116785
More information about the cfe-commits
mailing list