Fix the behavior of variable symbols in regard to cheap locals. Previously
every assignment to a variable symbol opened the same scope for cheap locals. So when redefining a variable symbol, an old cheap local scope was reopened which was unexpected and confusing. The change fixes this so that only the first definition of a variable symbol opens a new scope for cheap locals, but redefinitions of the same symbol do not.
This commit is contained in:
@@ -211,6 +211,8 @@ static void SymReplaceExprRefs (SymEntry* S)
|
||||
void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags)
|
||||
/* Define a new symbol */
|
||||
{
|
||||
int Redef = 0; /* Flag for symbol redefinition */
|
||||
|
||||
if (S->Flags & SF_IMPORT) {
|
||||
/* Defined symbol is marked as imported external symbol */
|
||||
Error ("Symbol '%m%p' is already an import", GetSymName (S));
|
||||
@@ -238,6 +240,7 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags
|
||||
*/
|
||||
FreeExpr (S->Expr);
|
||||
S->Expr = 0;
|
||||
Redef = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,8 +294,10 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags
|
||||
}
|
||||
}
|
||||
|
||||
/* If this is not a local symbol, remember it as the last global one */
|
||||
if ((S->Flags & SF_LOCAL) == 0) {
|
||||
/* If this is not a local symbol and not a redefinition for a variable
|
||||
** symbol, remember it as the last global one.
|
||||
*/
|
||||
if ((S->Flags & SF_LOCAL) == 0 && !Redef) {
|
||||
SymLast = S;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user