From: cuz Date: Thu, 14 Nov 2002 22:52:10 +0000 (+0000) Subject: Fixed a bug X-Git-Tag: V2.12.0~2111 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b1cc64faaa8467d975c1a0440b9d5f82fe22123d;p=cc65 Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@1521 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/typecast.c b/src/cc65/typecast.c index ec1111a80..bd9641761 100644 --- a/src/cc65/typecast.c +++ b/src/cc65/typecast.c @@ -78,24 +78,21 @@ int TypeCast (ExprDesc* lval) lval->Type = PointerTo (lval->Type); } - /* Remember the old type and use the new one */ + /* Remember the old type */ OldType = lval->Type; - lval->Type = TypeDup (NewType); /* If we're casting to void, we're done. Note: This does also cover a cast * void -> void. */ 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 - * set which should avoid more errors, but code will not get generated - * because of the error. - */ + /* Don't allow casts from void to something else. */ if (IsTypeVoid (OldType)) { 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 @@ -201,6 +198,10 @@ int TypeCast (ExprDesc* lval) } } +ExitPoint: + /* The expression has always the new type */ + ReplaceType (lval, NewType); + /* Done */ return k; }