1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 17:30:50 +00:00

Made the code handling '&expression' slightly tidier.

This commit is contained in:
acqn 2020-07-19 21:23:08 +08:00 committed by Oliver Schmidt
parent 3c52ad1d9e
commit 62a6e37487

View File

@ -1867,23 +1867,23 @@ void hie10 (ExprDesc* Expr)
NextToken (); NextToken ();
ExprWithCheck (hie10, Expr); ExprWithCheck (hie10, Expr);
/* The & operator may be applied to any lvalue, and it may be /* The & operator may be applied to any lvalue, and it may be
** applied to functions, even if they're no lvalues. ** applied to functions and arrays, even if they're not lvalues.
*/ */
if (ED_IsRVal (Expr) && !IsTypeFunc (Expr->Type) && !IsTypeArray (Expr->Type)) { if (!IsTypeFunc (Expr->Type) && !IsTypeArray (Expr->Type)) {
if (ED_IsRVal (Expr)) {
Error ("Illegal address"); Error ("Illegal address");
} else { break;
}
if (ED_IsBitField (Expr)) { if (ED_IsBitField (Expr)) {
Error ("Cannot take address of bit-field"); Error ("Cannot take address of bit-field");
/* Do it anyway, just to avoid further warnings */ /* Do it anyway, just to avoid further warnings */
Expr->Flags &= ~E_BITFIELD; ED_DisBitField (Expr);
} }
/* It's allowed in C to take the address of an array this way */
if (!IsTypeFunc (Expr->Type) && !IsTypeArray (Expr->Type)) {
/* The & operator yields an rvalue address */ /* The & operator yields an rvalue address */
ED_AddrExpr (Expr); ED_AddrExpr (Expr);
} }
Expr->Type = PointerTo (Expr->Type); Expr->Type = PointerTo (Expr->Type);
}
break; break;
case TOK_SIZEOF: case TOK_SIZEOF: