Skip to content

-Wpreferred-type-bitfield-enum-conversion reported in include/clang/Basic/LangOptions.def (FPEvalMethod) #137600

Open
@firewave

Description

@firewave

Doing a downstream include-what-you-use build with Clang 21 against LLVM 21 shows the following warning:

In file included from /mnt/s/GitHub/include-what-you-use/iwyu_globals.cc:22:
In file included from /usr/lib/llvm-21/include/clang/AST/PrettyPrinter.h:17:
In file included from /usr/lib/llvm-21/include/clang/Basic/LangOptions.h:663:
/usr/lib/llvm-21/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")
      | ^
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:67:6: note: expanded from macro 'BENIGN_ENUM_LANGOPT'
   67 |      COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
      |      ^
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:62:6: note: expanded from macro 'COMPATIBLE_ENUM_LANGOPT'
   62 |      ENUM_LANGOPT(Name, Type, Bits, Default, Description)
      |      ^
/usr/lib/llvm-21/include/clang/Basic/LangOptions.h:661:10: note: expanded from macro 'ENUM_LANGOPT'
  661 |     Name = static_cast<unsigned>(Value);                                       \
      |          ^
/usr/lib/llvm-21/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")
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:67:6: note: expanded from macro 'BENIGN_ENUM_LANGOPT'
   67 |      COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:62:6: note: expanded from macro 'COMPATIBLE_ENUM_LANGOPT'
   62 |      ENUM_LANGOPT(Name, Type, Bits, Default, Description)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/llvm-21/include/clang/Basic/LangOptions.h:501:3: note: expanded from macro 'ENUM_LANGOPT'
  501 |   unsigned Name : Bits;
      |   ^~~~~~~~
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:350:1: note: preferred type for bit-field 'FPEvalMethodKind' specified here
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:67:6: note: expanded from macro 'BENIGN_ENUM_LANGOPT'
   67 |      COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
      |      ^
/usr/lib/llvm-21/include/clang/Basic/LangOptions.def:62:6: note: expanded from macro 'COMPATIBLE_ENUM_LANGOPT'
   62 |      ENUM_LANGOPT(Name, Type, Bits, Default, Description)
      |      ^
/usr/lib/llvm-21/include/clang/Basic/LangOptions.h:500:3: note: expanded from macro 'ENUM_LANGOPT'
  500 |   LLVM_PREFERRED_TYPE(Type) \
      |   ^
/usr/lib/llvm-21/include/llvm/Support/Compiler.h:708:47: note: expanded from macro 'LLVM_PREFERRED_TYPE'
  708 | #define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T)))
      |                                               ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categorycode-quality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions