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

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 09:53:53 PDT 2023


Endilll wrote:

> There's some danger here. _BitInt is a C23 feature as are enumerations with a fixed underlying type. Enumerations with a fixed underlying type explicitly disallow using a bit-precise integer type as the underlying type. See C23 6.7.2.2p4, which says in part, "For all the integer constant expressions which make up the values of the enumeration constants, there shall be a type capable of representing all the values that is a standard or extended signed or unsigned integer type, or char.".

Thank you for pointing out to this! But it's not clear to me whether this was an explicit decision to not add bit-precise integers here, or just nobody cared enough to push for that. Because use case we have on our hands seems legit to me.

> Would it perhaps make sense to handle the common path first, see what usage experience finds in the wild, and then consider non_storable in the future?

Yeah, we should collect more evidence once we start sprinkle `preferred_type` around, with relevant diagnostics enabled (and implemented).

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


More information about the cfe-commits mailing list