From a70d466e3e74f07fdb91919696ef7bb92b4edcbb Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 17 Aug 2003 15:20:18 +0000 Subject: [PATCH] Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@2351 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/expr.c | 14 +++++++++++--- src/cc65/typeconv.c | 19 ++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 89e708e0d..702f89c12 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -589,9 +589,17 @@ static unsigned FunctionParamList (FuncDesc* Func) } else { unsigned ArgSize = sizeofarg (Flags); if (FrameSize > 0) { - /* We have the space already allocated, store in the frame */ - CHECK (FrameSize >= ArgSize); - FrameSize -= ArgSize; + /* We have the space already allocated, store in the frame. + * Because of invalid type conversions (that have produced an + * error before), we can end up here with a non aligned stack + * frame. Since no output will be generated anyway, handle + * these cases gracefully instead of doing a CHECK. + */ + if (FrameSize >= ArgSize) { + FrameSize -= ArgSize; + } else { + FrameSize = 0; + } FrameOffs -= ArgSize; /* Store */ g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.ConstVal); diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index 38ac2013f..35662ec88 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -207,11 +207,10 @@ int TypeConversion (ExprDesc* Expr, int k, type* NewType) Warning ("Converting pointer to integer without a cast"); } else if (!IsClassInt (Expr->Type)) { Error ("Incompatible types"); - } else { - /* Convert the rhs to the type of the lhs. */ - k = DoConversion (Expr, k, NewType); - } - return k; + } + + /* Do a conversion regardless of errors and return the result. */ + return DoConversion (Expr, k, NewType); } /* Handle conversions to pointer type */ @@ -228,11 +227,11 @@ int TypeConversion (ExprDesc* Expr, int k, type* NewType) case TC_INCOMPATIBLE: Error ("Incompatible pointer types"); - return k; + break; case TC_QUAL_DIFF: Error ("Pointer types differ in type qualifiers"); - return k; + break; default: /* Ok */ @@ -250,21 +249,19 @@ int TypeConversion (ExprDesc* Expr, int k, type* NewType) */ if (TypeCmp (Indirect (NewType), Expr->Type) < TC_EQUAL) { Error ("Incompatible types"); - return k; } } else { Error ("Incompatible types"); - return k; } - /* If we come here, the conversion is ok, convert and return the result */ + /* Do the conversion even in case of errors */ return DoConversion (Expr, k, NewType); } /* Invalid automatic conversion */ Error ("Incompatible types"); - return k; + return DoConversion (Expr, k, NewType); } -- 2.39.5