Issue 137603
Summary `-Wpreferred-type-bitfield-enum-conversion` reported in `include/clang/Basic/LangOptions.def` (ComplexRange)
Labels code-quality
Assignees
Reporter firewave
    Compiling `include-what-you-use` with Clang 21 against LLVM 20 shows the following:

```
In file included from /mnt/s/GitHub/include-what-you-use/iwyu_globals.cc:22:
In file included from /usr/lib/llvm-20/include/clang/AST/PrettyPrinter.h:17:
In file included from /usr/lib/llvm-20/include/clang/Basic/LangOptions.h:649:
/usr/lib/llvm-20/include/clang/Basic/LangOptions.def:242:1: warning: bit-field 'ComplexRange' is not wide enough to store all enumerators of preferred type 'ComplexRangeKind' [-Wpreferred-type-bitfield-enum-conversion]
  242 | ENUM_LANGOPT(ComplexRange, ComplexRangeKind, 2, CX_None, "Enable use of range reduction for complex arithmetics.")
      | ^
/usr/lib/llvm-20/include/clang/Basic/LangOptions.h:648:37: note: expanded from macro 'ENUM_LANGOPT'
  648 |   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
      | ^
/usr/lib/llvm-20/include/clang/Basic/LangOptions.def:242:46: note: widen this field to 3 bits to store all values of 'ComplexRangeKind'
  242 | ENUM_LANGOPT(ComplexRange, ComplexRangeKind, 2, CX_None, "Enable use of range reduction for complex arithmetics.")
      | ^
/usr/lib/llvm-20/include/clang/Basic/LangOptions.def:242:1: note: preferred type for bit-field 'ComplexRangeKind' specified here
  242 | ENUM_LANGOPT(ComplexRange, ComplexRangeKind, 2, CX_None, "Enable use of range reduction for complex arithmetics.")
      | ^
/usr/lib/llvm-20/include/clang/Basic/LangOptions.h:495:3: note: expanded from macro 'ENUM_LANGOPT'
  495 |   LLVM_PREFERRED_TYPE(Type) \
      | ^
/usr/lib/llvm-20/include/llvm/Support/Compiler.h:687:47: note: expanded from macro 'LLVM_PREFERRED_TYPE'
  687 | #define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T)))
      | ^
```

This does not happen when you compile with Clang 21 against LLVM 21. So this either needs a backport or can be closed as already fixed.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to