[clang] [clang] Add clang::debug_info_type attribute for bitfields (PR #69104)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 00:05:30 PDT 2023


Endilll wrote:

@erichkeane I guess you'd be pretty happy if our enums were declared the following way:
```cpp
enum E : unsigned _BitInt(4) {
  e0 = 16,
};
```
Then you'd be warned on the spot if you have more values than bits can hold, and bit-fields side check would be trivial to implement:
```
<source>:3:8: error: enumerator value evaluates to 16, which cannot be narrowed to type 'unsigned _BitInt(4)' [-Wc++11-narrowing]
  e0 = 16,
```
Unfortunately, Clang 14+ is the only major implementation that accepts this: https://godbolt.org/z/9rn87d8hc

https://github.com/llvm/llvm-project/pull/69104


More information about the cfe-commits mailing list