BUGFIX: Occurrence of multiple macro symbols in one tuple could lead to infinite loop.
The mechanism with the next pointers for tac's was working fine as long as all tac's were unique by construction. The macro mechanism made it possible for the same tac to occur twice in the tree. This could lead to an infinite loop. Now we make explicit copies of the top-level tac. This should fix the problem caused by the tuple parsing. A more fundamental solution is to make a deep copy of the substituted terms.
This commit is contained in:
parent
1b4eb7cb54
commit
a71fe51036
@ -423,7 +423,7 @@ basicormacro : ID
|
||||
Tac macrotac;
|
||||
|
||||
macrotac = (Tac) l->data;
|
||||
t = macrotac->t2.tac;
|
||||
t = tacCopy(macrotac->t2.tac);
|
||||
}
|
||||
$$ = t;
|
||||
}
|
||||
|
16
src/tac.c
16
src/tac.c
@ -52,6 +52,22 @@ tacDone (void)
|
||||
}
|
||||
}
|
||||
|
||||
//! Copy a tac
|
||||
Tac
|
||||
tacCopy(Tac c)
|
||||
{
|
||||
Tac newTac;
|
||||
|
||||
newTac = (Tac) malloc (sizeof (struct tacnode));
|
||||
memcpy (newTac, c, sizeof (struct tacnode));
|
||||
|
||||
// Store in taclist
|
||||
newTac->allnext = allocatedTacs;
|
||||
allocatedTacs = newTac;
|
||||
|
||||
return newTac;
|
||||
}
|
||||
|
||||
//! Create a tac node of some type
|
||||
Tac
|
||||
tacCreate (int op)
|
||||
|
Loading…
Reference in New Issue
Block a user