Do not try to dump an expression that has errors (circular references in this
case) because the dump routine doesn't detect this and runs into an endless recursion. git-svn-id: svn://svn.cc65.org/cc65/trunk@5811 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -106,11 +106,19 @@ int ED_IsConst (const ExprDesc* D)
|
|||||||
|
|
||||||
|
|
||||||
static int ED_IsValid (const ExprDesc* D)
|
static int ED_IsValid (const ExprDesc* D)
|
||||||
/* Return true if the expression is valid, that is, the TOO_COMPLEX flag is
|
/* Return true if the expression is valid, that is, neither the ERROR nor the
|
||||||
* not set
|
* TOO_COMPLEX flags are set.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
return ((D->Flags & ED_TOO_COMPLEX) == 0);
|
return ((D->Flags & (ED_ERROR | ED_TOO_COMPLEX)) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int ED_HasError (const ExprDesc* D)
|
||||||
|
/* Return true if the expression has an error. */
|
||||||
|
{
|
||||||
|
return ((D->Flags & ED_ERROR) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,6 +131,14 @@ static void ED_Invalidate (ExprDesc* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void ED_SetError (ExprDesc* D)
|
||||||
|
/* Set the TOO_COMPLEX and ERROR flags for D */
|
||||||
|
{
|
||||||
|
D->Flags |= (ED_ERROR | ED_TOO_COMPLEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ED_UpdateAddrSize (ExprDesc* ED, unsigned char AddrSize)
|
static void ED_UpdateAddrSize (ExprDesc* ED, unsigned char AddrSize)
|
||||||
/* Update the address size of the expression */
|
/* Update the address size of the expression */
|
||||||
{
|
{
|
||||||
@@ -507,13 +523,10 @@ static void StudySymbol (ExprNode* Expr, ExprDesc* D)
|
|||||||
if (SymHasExpr (Sym)) {
|
if (SymHasExpr (Sym)) {
|
||||||
|
|
||||||
if (SymHasUserMark (Sym)) {
|
if (SymHasUserMark (Sym)) {
|
||||||
if (Verbosity > 0) {
|
|
||||||
DumpExpr (Expr, SymResolve);
|
|
||||||
}
|
|
||||||
LIError (&Sym->DefLines,
|
LIError (&Sym->DefLines,
|
||||||
"Circular reference in definition of symbol `%m%p'",
|
"Circular reference in definition of symbol `%m%p'",
|
||||||
GetSymName (Sym));
|
GetSymName (Sym));
|
||||||
ED_Invalidate (D);
|
ED_SetError (D);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
unsigned char AddrSize;
|
unsigned char AddrSize;
|
||||||
@@ -523,6 +536,11 @@ static void StudySymbol (ExprNode* Expr, ExprDesc* D)
|
|||||||
StudyExprInternal (GetSymExpr (Sym), D);
|
StudyExprInternal (GetSymExpr (Sym), D);
|
||||||
SymUnmarkUser (Sym);
|
SymUnmarkUser (Sym);
|
||||||
|
|
||||||
|
/* If requested and if the expression is valid, dump it */
|
||||||
|
if (Verbosity > 0 && !ED_HasError (D)) {
|
||||||
|
DumpExpr (Expr, SymResolve);
|
||||||
|
}
|
||||||
|
|
||||||
/* If the symbol has an explicit address size, use it. This may
|
/* If the symbol has an explicit address size, use it. This may
|
||||||
* lead to range errors later (maybe even in the linker stage), if
|
* lead to range errors later (maybe even in the linker stage), if
|
||||||
* the user lied about the address size, but for now we trust him.
|
* the user lied about the address size, but for now we trust him.
|
||||||
@@ -733,7 +751,7 @@ static void StudyDiv (ExprNode* Expr, ExprDesc* D)
|
|||||||
if (ED_IsValid (D)) {
|
if (ED_IsValid (D)) {
|
||||||
if (D->Right == 0) {
|
if (D->Right == 0) {
|
||||||
Error ("Division by zero");
|
Error ("Division by zero");
|
||||||
ED_Invalidate (D);
|
ED_SetError (D);
|
||||||
} else {
|
} else {
|
||||||
D->Val /= D->Right;
|
D->Val /= D->Right;
|
||||||
}
|
}
|
||||||
@@ -752,7 +770,7 @@ static void StudyMod (ExprNode* Expr, ExprDesc* D)
|
|||||||
if (ED_IsValid (D)) {
|
if (ED_IsValid (D)) {
|
||||||
if (D->Right == 0) {
|
if (D->Right == 0) {
|
||||||
Error ("Modulo operation with zero");
|
Error ("Modulo operation with zero");
|
||||||
ED_Invalidate (D);
|
ED_SetError (D);
|
||||||
} else {
|
} else {
|
||||||
D->Val %= D->Right;
|
D->Val %= D->Right;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003 Ullrich von Bassewitz */
|
/* (C) 2003-2012, Ullrich von Bassewitz */
|
||||||
/* R<EFBFBD>merstra<EFBFBD>e 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
/* Flags */
|
/* Flags */
|
||||||
#define ED_OK 0x00 /* Nothing special */
|
#define ED_OK 0x00 /* Nothing special */
|
||||||
#define ED_TOO_COMPLEX 0x01 /* Expression is too complex */
|
#define ED_TOO_COMPLEX 0x01 /* Expression is too complex */
|
||||||
|
#define ED_ERROR 0x02 /* Error evaluating the expression */
|
||||||
|
|
||||||
/* Symbol reference */
|
/* Symbol reference */
|
||||||
typedef struct ED_SymRef ED_SymRef;
|
typedef struct ED_SymRef ED_SymRef;
|
||||||
|
|||||||
Reference in New Issue
Block a user