Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1521 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -78,24 +78,21 @@ int TypeCast (ExprDesc* lval)
|
|||||||
lval->Type = PointerTo (lval->Type);
|
lval->Type = PointerTo (lval->Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remember the old type and use the new one */
|
/* Remember the old type */
|
||||||
OldType = lval->Type;
|
OldType = lval->Type;
|
||||||
lval->Type = TypeDup (NewType);
|
|
||||||
|
|
||||||
/* If we're casting to void, we're done. Note: This does also cover a cast
|
/* If we're casting to void, we're done. Note: This does also cover a cast
|
||||||
* void -> void.
|
* void -> void.
|
||||||
*/
|
*/
|
||||||
if (IsTypeVoid (NewType)) {
|
if (IsTypeVoid (NewType)) {
|
||||||
return 0; /* Never an lvalue */
|
k = 0; /* Never an lvalue */
|
||||||
|
goto ExitPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't allow casts from void to something else. The new type is already
|
/* Don't allow casts from void to something else. */
|
||||||
* set which should avoid more errors, but code will not get generated
|
|
||||||
* because of the error.
|
|
||||||
*/
|
|
||||||
if (IsTypeVoid (OldType)) {
|
if (IsTypeVoid (OldType)) {
|
||||||
Error ("Cannot cast from `void' to something else");
|
Error ("Cannot cast from `void' to something else");
|
||||||
return k;
|
goto ExitPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the sizes of the types. Since we've excluded void types, checking
|
/* Get the sizes of the types. Since we've excluded void types, checking
|
||||||
@@ -201,6 +198,10 @@ int TypeCast (ExprDesc* lval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExitPoint:
|
||||||
|
/* The expression has always the new type */
|
||||||
|
ReplaceType (lval, NewType);
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user