Fixed a bug

git-svn-id: svn://svn.cc65.org/cc65/trunk@1862 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2002-12-29 21:23:28 +00:00
parent e525cd2515
commit ed2bb59bcb

View File

@@ -1609,29 +1609,37 @@ int hie10 (ExprDesc* lval)
case TOK_BOOL_NOT: case TOK_BOOL_NOT:
NextToken (); NextToken ();
if (evalexpr (CF_NONE, hie10, lval) == 0) { if (evalexpr (CF_NONE, hie10, lval) == 0) {
/* Constant expression */ /* Constant expression */
lval->ConstVal = !lval->ConstVal; lval->ConstVal = !lval->ConstVal;
} else { } else {
g_bneg (TypeOf (lval->Type)); g_bneg (TypeOf (lval->Type));
lval->Test |= E_CC; /* bneg will set cc */ lval->Test |= E_CC; /* bneg will set cc */
lval->Flags = E_MEXPR; /* say it's an expr */ lval->Flags = E_MEXPR; /* say it's an expr */
} }
return 0; /* expr not storable */ return 0; /* expr not storable */
case TOK_STAR: case TOK_STAR:
NextToken (); NextToken ();
if (evalexpr (CF_NONE, hie10, lval) != 0) { if (evalexpr (CF_NONE, hie10, lval) != 0) {
/* Expression is not const, indirect value loaded into primary */ /* Expression is not const, indirect value loaded into primary */
lval->Flags = E_MEXPR; lval->Flags = E_MEXPR;
lval->ConstVal = 0; /* Offset is zero now */ lval->ConstVal = 0; /* Offset is zero now */
} }
t = lval->Type; /* If the expression is already a pointer to function, the
if (IsClassPtr (t)) { * additional dereferencing operator must be ignored.
lval->Type = Indirect (t); */
} else { if (IsTypeFuncPtr (lval->Type)) {
Error ("Illegal indirection"); /* Expression not storable */
} return 0;
return 1; } else {
if (IsClassPtr (lval->Type)) {
lval->Type = Indirect (lval->Type);
} else {
Error ("Illegal indirection");
}
return 1;
}
break;
case TOK_AND: case TOK_AND:
NextToken (); NextToken ();
@@ -1640,32 +1648,32 @@ int hie10 (ExprDesc* lval)
* applied to functions, even if they're no lvalues. * applied to functions, even if they're no lvalues.
*/ */
if (k == 0 && !IsTypeFunc (lval->Type)) { if (k == 0 && !IsTypeFunc (lval->Type)) {
/* Allow the & operator with an array */ /* Allow the & operator with an array */
if (!IsTypeArray (lval->Type)) { if (!IsTypeArray (lval->Type)) {
Error ("Illegal address"); Error ("Illegal address");
} }
} else { } else {
t = TypeAlloc (TypeLen (lval->Type) + 2); t = TypeAlloc (TypeLen (lval->Type) + 2);
t [0] = T_PTR; t [0] = T_PTR;
TypeCpy (t + 1, lval->Type); TypeCpy (t + 1, lval->Type);
lval->Type = t; lval->Type = t;
} }
return 0; return 0;
case TOK_SIZEOF: case TOK_SIZEOF:
NextToken (); NextToken ();
if (istypeexpr ()) { if (istypeexpr ()) {
type Type[MAXTYPELEN]; type Type[MAXTYPELEN];
NextToken (); NextToken ();
lval->ConstVal = CheckedSizeOf (ParseType (Type)); lval->ConstVal = CheckedSizeOf (ParseType (Type));
ConsumeRParen (); ConsumeRParen ();
} else { } else {
/* Remember the output queue pointer */ /* Remember the output queue pointer */
CodeMark Mark = GetCodePos (); CodeMark Mark = GetCodePos ();
hie10 (lval); hie10 (lval);
lval->ConstVal = CheckedSizeOf (lval->Type); lval->ConstVal = CheckedSizeOf (lval->Type);
/* Remove any generated code */ /* Remove any generated code */
RemoveCode (Mark); RemoveCode (Mark);
} }
lval->Flags = E_MCONST | E_TCONST; lval->Flags = E_MCONST | E_TCONST;
lval->Type = type_uint; lval->Type = type_uint;
@@ -1674,8 +1682,8 @@ int hie10 (ExprDesc* lval)
default: default:
if (istypeexpr ()) { if (istypeexpr ()) {
/* A cast */ /* A cast */
return TypeCast (lval); return TypeCast (lval);
} }
} }
@@ -1699,7 +1707,7 @@ int hie10 (ExprDesc* lval)
static int hie_internal (const GenDesc** ops, /* List of generators */ static int hie_internal (const GenDesc** ops, /* List of generators */
ExprDesc* lval, /* parent expr's lval */ ExprDesc* lval, /* parent expr's lval */
int (*hienext) (ExprDesc*), int (*hienext) (ExprDesc*),
int* UsedGen) /* next higher level */ int* UsedGen) /* next higher level */
/* Helper function */ /* Helper function */
{ {
int k; int k;