1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-26 17:36:57 +00:00

Fixed CHECK failures on certain usage of incomplete enums.

This commit is contained in:
acqn 2020-08-22 05:56:33 +08:00 committed by Oliver Schmidt
parent 1957dc7a5c
commit 43cb092a68
2 changed files with 15 additions and 3 deletions

View File

@ -686,7 +686,10 @@ const Type* GetUnderlyingType (const Type* Type)
Internal ("Enum tag type error in GetUnderlyingTypeCode");
}
return ((SymEntry*)Type->A.P)->V.E.Type;
/* If incomplete enum type is used, just return its raw type */
if (((SymEntry*)Type->A.P)->V.E.Type != 0) {
return ((SymEntry*)Type->A.P)->V.E.Type;
}
}
return Type;
@ -1246,9 +1249,14 @@ Type* IntPromotion (Type* T)
** to unsigned int.
*/
return IsSignUnsigned (T) ? type_uint : type_int;
} else {
/* Otherwise, the type is not smaller than int, so leave it alone. */
} else if (!IsIncompleteESUType (T)) {
/* The type is a complete type not smaller than int, so leave it alone. */
return T;
} else {
/* Otherwise, this is an incomplete enum, and there is expceted to be an error already.
** Assume int to avoid further errors.
*/
return type_int;
}
}

View File

@ -142,6 +142,10 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
BitFieldFullWidthFlags |= CF_UNSIGNED;
}
} else if ((Flags & CF_TYPEMASK) == 0) {
/* If Expr is an incomplete ESY type, bail out */
if (IsIncompleteESUType (Expr->Type)) {
return;
}
Flags |= TypeOf (Expr->Type);
}