1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Fixed ICE on error cases such as '&func + int a'.

This commit is contained in:
acqn 2021-03-29 14:30:44 +08:00 committed by Oliver Schmidt
parent 200b420562
commit 91fd30611a

View File

@ -2850,27 +2850,31 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
} else {
/* OOPS */
AddDone = -1;
/* Avoid further errors */
ED_MakeConstAbsInt (Expr, 0);
}
/* Do constant calculation if we can */
if (ED_IsAbs (&Expr2) &&
(ED_IsAbs (Expr) || lscale == 1)) {
if (IsClassInt (lhst) && IsClassInt (rhst)) {
Expr->Type = ArithmeticConvert (Expr->Type, Expr2.Type);
if (!AddDone) {
/* Do constant calculation if we can */
if (ED_IsAbs (&Expr2) &&
(ED_IsAbs (Expr) || lscale == 1)) {
if (IsClassInt (lhst) && IsClassInt (rhst)) {
Expr->Type = ArithmeticConvert (Expr->Type, Expr2.Type);
}
Expr->IVal = Expr->IVal * lscale + Expr2.IVal * rscale;
AddDone = 1;
} else if (ED_IsAbs (Expr) &&
(ED_IsAbs (&Expr2) || rscale == 1)) {
if (IsClassInt (lhst) && IsClassInt (rhst)) {
Expr2.Type = ArithmeticConvert (Expr2.Type, Expr->Type);
}
Expr2.IVal = Expr->IVal * lscale + Expr2.IVal * rscale;
/* Adjust the flags */
Expr2.Flags |= Expr->Flags & ~E_MASK_KEEP_SUBEXPR;
/* Get the symbol and the name */
*Expr = Expr2;
AddDone = 1;
}
Expr->IVal = Expr->IVal * lscale + Expr2.IVal * rscale;
AddDone = 1;
} else if (ED_IsAbs (Expr) &&
(ED_IsAbs (&Expr2) || rscale == 1)) {
if (IsClassInt (lhst) && IsClassInt (rhst)) {
Expr2.Type = ArithmeticConvert (Expr2.Type, Expr->Type);
}
Expr2.IVal = Expr->IVal * lscale + Expr2.IVal * rscale;
/* Adjust the flags */
Expr2.Flags |= Expr->Flags & ~E_MASK_KEEP_SUBEXPR;
/* Get the symbol and the name */
*Expr = Expr2;
AddDone = 1;
}
if (AddDone) {