Fixed a bug

git-svn-id: svn://svn.cc65.org/cc65/trunk@2351 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-08-17 15:20:18 +00:00
parent aa87296c1f
commit a70d466e3e
2 changed files with 19 additions and 14 deletions

View File

@@ -589,9 +589,17 @@ static unsigned FunctionParamList (FuncDesc* Func)
} else { } else {
unsigned ArgSize = sizeofarg (Flags); unsigned ArgSize = sizeofarg (Flags);
if (FrameSize > 0) { if (FrameSize > 0) {
/* We have the space already allocated, store in the frame */ /* We have the space already allocated, store in the frame.
CHECK (FrameSize >= ArgSize); * Because of invalid type conversions (that have produced an
FrameSize -= ArgSize; * 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; FrameOffs -= ArgSize;
/* Store */ /* Store */
g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.ConstVal); g_putlocal (Flags | CF_NOKEEP, FrameOffs, lval.ConstVal);

View File

@@ -207,11 +207,10 @@ int TypeConversion (ExprDesc* Expr, int k, type* NewType)
Warning ("Converting pointer to integer without a cast"); Warning ("Converting pointer to integer without a cast");
} else if (!IsClassInt (Expr->Type)) { } else if (!IsClassInt (Expr->Type)) {
Error ("Incompatible types"); Error ("Incompatible types");
} else { }
/* Convert the rhs to the type of the lhs. */
k = DoConversion (Expr, k, NewType); /* Do a conversion regardless of errors and return the result. */
} return DoConversion (Expr, k, NewType);
return k;
} }
/* Handle conversions to pointer type */ /* Handle conversions to pointer type */
@@ -228,11 +227,11 @@ int TypeConversion (ExprDesc* Expr, int k, type* NewType)
case TC_INCOMPATIBLE: case TC_INCOMPATIBLE:
Error ("Incompatible pointer types"); Error ("Incompatible pointer types");
return k; break;
case TC_QUAL_DIFF: case TC_QUAL_DIFF:
Error ("Pointer types differ in type qualifiers"); Error ("Pointer types differ in type qualifiers");
return k; break;
default: default:
/* Ok */ /* Ok */
@@ -250,21 +249,19 @@ int TypeConversion (ExprDesc* Expr, int k, type* NewType)
*/ */
if (TypeCmp (Indirect (NewType), Expr->Type) < TC_EQUAL) { if (TypeCmp (Indirect (NewType), Expr->Type) < TC_EQUAL) {
Error ("Incompatible types"); Error ("Incompatible types");
return k;
} }
} else { } else {
Error ("Incompatible types"); 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); return DoConversion (Expr, k, NewType);
} }
/* Invalid automatic conversion */ /* Invalid automatic conversion */
Error ("Incompatible types"); Error ("Incompatible types");
return k; return DoConversion (Expr, k, NewType);
} }