Merge pull request #1358 from dmsc/issue-479
Fixes Issue 479 (ca65: can't reference .proc members before declaration)
This commit is contained in:
@@ -646,10 +646,14 @@ static void StudySymbol (ExprNode* Expr, ExprDesc* D)
|
||||
** about the address size, check higher lexical levels for a symbol
|
||||
** with the same name and use its address size if we find such a
|
||||
** symbol which is defined.
|
||||
**
|
||||
** Only do the search if the symbol is not in the current scope,
|
||||
** assume scoped symbols can't be resolved in a different scope.
|
||||
*/
|
||||
AddrSize = GetSymAddrSize (Sym);
|
||||
Parent = GetSymParentScope (Sym);
|
||||
if (AddrSize == ADDR_SIZE_DEFAULT && Parent != 0) {
|
||||
if (AddrSize == ADDR_SIZE_DEFAULT && Parent != 0 &&
|
||||
Sym->Sym.Tab == CurrentScope) {
|
||||
SymEntry* H = SymFindAny (Parent, GetSymName (Sym));
|
||||
if (H) {
|
||||
AddrSize = GetSymAddrSize (H);
|
||||
|
||||
@@ -94,10 +94,14 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName)
|
||||
*/
|
||||
Scope = SymFindAnyScope (CurrentScope, Name);
|
||||
if (Scope == 0) {
|
||||
/* Scope not found */
|
||||
SB_Terminate (FullName);
|
||||
Error ("No such scope: `%m%p'", FullName);
|
||||
return 0;
|
||||
/* Scope not found, create a new scope here */
|
||||
Scope = SymFindScope (CurrentScope, Name, SYM_ALLOC_NEW);
|
||||
if (Scope == 0) {
|
||||
SB_Terminate (FullName);
|
||||
/* Scope not found */
|
||||
Error ("Can't create scope: `%m%p'", FullName);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -136,10 +140,10 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName)
|
||||
SB_Append (FullName, Name);
|
||||
|
||||
/* Search for the child scope */
|
||||
Scope = SymFindScope (Scope, Name, SYM_FIND_EXISTING);
|
||||
Scope = SymFindScope (Scope, Name, SYM_ALLOC_NEW);
|
||||
if (Scope == 0) {
|
||||
/* Scope not found */
|
||||
Error ("No such scope: `%m%p'", FullName);
|
||||
Error ("Can't create scope: `%m%p'", FullName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +218,8 @@ void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type,
|
||||
if (CurrentScope->Flags & ST_DEFINED) {
|
||||
Error ("Duplicate scope `%m%p'", ScopeName);
|
||||
}
|
||||
/* Open the scope as we are entering it */
|
||||
CurrentScope->Flags &= ~ST_CLOSED;
|
||||
|
||||
} else {
|
||||
CurrentScope = RootScope = NewSymTable (0, ScopeName);
|
||||
@@ -294,6 +296,8 @@ SymTable* SymFindScope (SymTable* Parent, const StrBuf* Name, SymFindAction Acti
|
||||
/* Create a new scope if requested and we didn't find one */
|
||||
if (*T == 0 && (Action & SYM_ALLOC_NEW) != 0) {
|
||||
*T = NewSymTable (Parent, Name);
|
||||
/* Close the created scope, will be reopened if needed */
|
||||
(*T)->Flags |= ST_CLOSED;
|
||||
}
|
||||
|
||||
/* Return the scope */
|
||||
|
||||
Reference in New Issue
Block a user