1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Added code that avoids infinite loops that were caused by circular references

(a symbol that was defined by referring to itself directly or indirectly).  Patch by kugelfuhr.
This commit is contained in:
Greg King 2022-02-12 04:48:47 -05:00 committed by mrdudz
parent 2628a176f9
commit 800568dd58

View File

@ -171,6 +171,25 @@ int IsFarRange (long Val)
static const ExprNode* ResolveSymbolChain(const ExprNode* E)
/* Recursive helper function for IsEasyConst */
{
if (E->Op == EXPR_SYMBOL) {
SymEntry* Sym = E->V.Sym;
if (Sym == 0 || Sym->Expr == 0 || SymHasUserMark (Sym)) {
return 0;
} else {
SymMarkUser (Sym);
E = ResolveSymbolChain (Sym->Expr);
SymUnmarkUser (Sym);
}
}
return E;
}
int IsEasyConst (const ExprNode* E, long* Val)
/* Do some light checking if the given node is a constant. Don't care if E is
** a complex expression. If E is a constant, return true and place its value
@ -178,12 +197,10 @@ int IsEasyConst (const ExprNode* E, long* Val)
*/
{
/* Resolve symbols, follow symbol chains */
while (E->Op == EXPR_SYMBOL) {
E = SymResolve (E->V.Sym);
if (E == 0) {
/* Could not resolve */
return 0;
}
E = ResolveSymbolChain (E);
if (E == 0) {
/* Could not resolve */
return 0;
}
/* Symbols resolved, check for a literal */