Corrected _BitInt enum handling in GCC's type functions
GCC's type handling now correctly processes enums based on _BitInt types, fixing a bug in signed/unsigned type determination.
A bug in GCC’s signed_or_unsigned_type_for function related to C23 enums with underlying _BitInt types has been fixed. The function now correctly returns the underlying _BitInt type instead of attempting to build a non-standard integer type, ensuring proper type compatibility.
In Details
The signed_or_unsigned_type_for function in tree.cc did not correctly handle ENUMERAL_TYPEs whose underlying type is BITINT_TYPE. When processing C23 enums with _BitInt underlying types, it incorrectly called build_nonstandard_integer_type. This patch modifies the function to test BITINT_TYPE_P(type) and call build_bitint_type when appropriate, ensuring it returns the correct underlying _BitInt type for these enumerations.
- _BitInt
- A C23 language feature that allows programmers to specify integer types with arbitrary bit widths, rather than being restricted to fixed sizes like 8, 16, 32, or 64 bits.
- ENUMERAL_TYPE
- A GCC internal tree code representing an enumerated type, which consists of a set of named integer constants.
- BITINT_TYPE_P
- A GCC internal macro that checks if a given tree node represents a bit-integer type. This is used to identify and handle custom-width integer types.
- tree.cc
- A source file within the GCC compiler that contains core logic for manipulating the compiler's internal abstract syntax tree (AST) representation, known as 'tree'.
- signed_or_unsigned_type_for
- A GCC internal function that determines the corresponding signed or unsigned type for a given type, often used during type promotion or canonicalization.