mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Merge pull request #318 from mid-kid/patch-316
Update a symbol's filename and line when defined
This commit is contained in:
@@ -102,6 +102,19 @@ uint32_t calchash(char *s)
|
|||||||
return hash % HASHSIZE;
|
return hash % HASHSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update a symbol's definition filename and line
|
||||||
|
*/
|
||||||
|
void updateSymbolFilename(struct sSymbol *nsym)
|
||||||
|
{
|
||||||
|
if (snprintf(nsym->tzFileName, _MAX_PATH + 1, "%s",
|
||||||
|
tzCurrentFileName) > _MAX_PATH) {
|
||||||
|
fatalerror("%s: File name is too long: '%s'", __func__,
|
||||||
|
tzCurrentFileName);
|
||||||
|
}
|
||||||
|
nsym->nFileLine = fstk_GetLine();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new symbol by name
|
* Create a new symbol by name
|
||||||
*/
|
*/
|
||||||
@@ -133,14 +146,7 @@ struct sSymbol *createsymbol(char *s)
|
|||||||
(*ppsym)->pMacro = NULL;
|
(*ppsym)->pMacro = NULL;
|
||||||
(*ppsym)->pSection = NULL;
|
(*ppsym)->pSection = NULL;
|
||||||
(*ppsym)->Callback = NULL;
|
(*ppsym)->Callback = NULL;
|
||||||
|
updateSymbolFilename(*ppsym);
|
||||||
if (snprintf((*ppsym)->tzFileName, _MAX_PATH + 1, "%s",
|
|
||||||
tzCurrentFileName) > _MAX_PATH) {
|
|
||||||
fatalerror("%s: File name is too long: '%s'", __func__,
|
|
||||||
tzCurrentFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
(*ppsym)->nFileLine = fstk_GetLine();
|
|
||||||
return *ppsym;
|
return *ppsym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,6 +566,7 @@ void sym_AddEqu(char *tzSym, int32_t value)
|
|||||||
nsym->nValue = value;
|
nsym->nValue = value;
|
||||||
nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
|
nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
|
||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -633,6 +640,7 @@ void sym_AddSet(char *tzSym, int32_t value)
|
|||||||
nsym->nValue = value;
|
nsym->nValue = value;
|
||||||
nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
|
nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
|
||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,6 +718,8 @@ void sym_AddReloc(char *tzSym)
|
|||||||
|
|
||||||
nsym->pScope = scope;
|
nsym->pScope = scope;
|
||||||
nsym->pSection = pCurrentSection;
|
nsym->pSection = pCurrentSection;
|
||||||
|
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pScope = findsymbol(tzSym, scope);
|
pScope = findsymbol(tzSym, scope);
|
||||||
@@ -840,6 +850,7 @@ void sym_AddMacro(char *tzSym)
|
|||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
nsym->ulMacroSize = ulNewMacroSize;
|
nsym->ulMacroSize = ulNewMacroSize;
|
||||||
nsym->pMacro = tzNewMacro;
|
nsym->pMacro = tzNewMacro;
|
||||||
|
updateSymbolFilename(nsym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
test/asm/label-redefinition.asm
Normal file
7
test/asm/label-redefinition.asm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
SECTION "sec", ROM0
|
||||||
|
dw Sym
|
||||||
|
m: MACRO
|
||||||
|
Sym::
|
||||||
|
ENDM
|
||||||
|
m
|
||||||
|
Sym::
|
||||||
3
test/asm/label-redefinition.out
Normal file
3
test/asm/label-redefinition.out
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ERROR: label-redefinition.asm(7):
|
||||||
|
'Sym' already defined in m(6)
|
||||||
|
error: Assembly aborted in pass 1 (1 errors)!
|
||||||
Reference in New Issue
Block a user