Fix enum bit-field ICE #1244
This previously resulted in an ICE: cc65: Check failed: (Entry->Type->C & T_MASK_SIGN) == T_SIGN_SIGNED, file 'cc65/symtab.c', line 874 This CHECK is in the code that deals with changing `int` bitfields to `unsigned int`. Work around this by treating enum bit-fields as having their signedness specified, so this type change code does not get called. Fixes #1244.
This commit is contained in:
committed by
Oliver Schmidt
parent
1e7a9e44af
commit
9a0e4a35e1
@@ -1446,6 +1446,12 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers,
|
||||
D->Type[0].C |= T_ENUM;
|
||||
SetESUSymEntry (D->Type, Entry);
|
||||
D->Type[1].C = T_END;
|
||||
/* The signedness of enums is determined by the type, so say this is specified to avoid
|
||||
** the int -> unsigned int handling for plain int bit-fields in AddBitField.
|
||||
*/
|
||||
if (SignednessSpecified) {
|
||||
*SignednessSpecified = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case TOK_IDENT:
|
||||
|
||||
@@ -870,6 +870,7 @@ SymEntry* AddBitField (const char* Name, const Type* T, unsigned Offs,
|
||||
if (!SignednessSpecified) {
|
||||
/* int is treated as signed int everywhere except bit-fields; switch it to unsigned,
|
||||
** since this is allowed for bit-fields and avoids sign-extension, so is much faster.
|
||||
** enums set SignednessSpecified to 1 to avoid this adjustment.
|
||||
*/
|
||||
CHECK ((Entry->Type->C & T_MASK_SIGN) == T_SIGN_SIGNED);
|
||||
Entry->Type->C &= ~T_MASK_SIGN;
|
||||
|
||||
Reference in New Issue
Block a user