Improved diagnostics.
This commit is contained in:
@@ -2235,7 +2235,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
|||||||
{ ccNone, DoUnexpected }, /* .REF, .REFERENCED */
|
{ ccNone, DoUnexpected }, /* .REF, .REFERENCED */
|
||||||
{ ccNone, DoReferTo }, /* .REFTO, .REFERTO */
|
{ ccNone, DoReferTo }, /* .REFTO, .REFERTO */
|
||||||
{ ccNone, DoReloc }, /* .RELOC */
|
{ ccNone, DoReloc }, /* .RELOC */
|
||||||
{ ccNone, DoRepeat }, /* .REPEAT */
|
{ ccKeepToken, DoRepeat }, /* .REPEAT */
|
||||||
{ ccNone, DoRes }, /* .RES */
|
{ ccNone, DoRes }, /* .RES */
|
||||||
{ ccNone, DoInvalid }, /* .RIGHT */
|
{ ccNone, DoInvalid }, /* .RIGHT */
|
||||||
{ ccNone, DoROData }, /* .RODATA */
|
{ ccNone, DoROData }, /* .RODATA */
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static TokList* CollectRepeatTokens (void)
|
static TokList* CollectRepeatTokens (const FilePos* StartPos)
|
||||||
/* Collect all tokens inside the .REPEAT body in a token list and return
|
/* Collect all tokens inside the .REPEAT body in a token list and return
|
||||||
** this list. In case of errors, NULL is returned.
|
** this list. In case of errors, NULL is returned.
|
||||||
*/
|
*/
|
||||||
@@ -67,7 +67,8 @@ static TokList* CollectRepeatTokens (void)
|
|||||||
|
|
||||||
/* Check for end of input */
|
/* Check for end of input */
|
||||||
if (CurTok.Tok == TOK_EOF) {
|
if (CurTok.Tok == TOK_EOF) {
|
||||||
Error ("Unexpected end of file");
|
ErrorExpect ("Expected '.ENDREPEAT'");
|
||||||
|
PNotification (StartPos, "For this '.REPEAT' command");
|
||||||
FreeTokList (List);
|
FreeTokList (List);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -117,6 +118,10 @@ void ParseRepeat (void)
|
|||||||
char* Name;
|
char* Name;
|
||||||
TokList* List;
|
TokList* List;
|
||||||
|
|
||||||
|
/* Remember the position of the .REPEAT token, then skip it */
|
||||||
|
FilePos StartPos = CurTok.Pos;
|
||||||
|
NextTok ();
|
||||||
|
|
||||||
/* Repeat count follows */
|
/* Repeat count follows */
|
||||||
long RepCount = ConstExpression ();
|
long RepCount = ConstExpression ();
|
||||||
if (RepCount < 0) {
|
if (RepCount < 0) {
|
||||||
@@ -145,7 +150,7 @@ void ParseRepeat (void)
|
|||||||
ConsumeSep ();
|
ConsumeSep ();
|
||||||
|
|
||||||
/* Read the token list */
|
/* Read the token list */
|
||||||
List = CollectRepeatTokens ();
|
List = CollectRepeatTokens (&StartPos);
|
||||||
|
|
||||||
/* If we had an error, bail out */
|
/* If we had an error, bail out */
|
||||||
if (List == 0) {
|
if (List == 0) {
|
||||||
|
|||||||
@@ -216,6 +216,10 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags
|
|||||||
if (S->Flags & SF_IMPORT) {
|
if (S->Flags & SF_IMPORT) {
|
||||||
/* Defined symbol is marked as imported external symbol */
|
/* Defined symbol is marked as imported external symbol */
|
||||||
Error ("Symbol '%m%p' is already an import", GetSymName (S));
|
Error ("Symbol '%m%p' is already an import", GetSymName (S));
|
||||||
|
if (CollCount (&S->DefLines) > 0) {
|
||||||
|
PNotification (GetSourcePos (CollAt(&S->DefLines, 0)),
|
||||||
|
"The symbol was previously imported here");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((Flags & SF_VAR) != 0 && (S->Flags & (SF_EXPORT | SF_GLOBAL))) {
|
if ((Flags & SF_VAR) != 0 && (S->Flags & (SF_EXPORT | SF_GLOBAL))) {
|
||||||
@@ -227,6 +231,10 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags
|
|||||||
/* Multiple definition. In case of a variable, this is legal. */
|
/* Multiple definition. In case of a variable, this is legal. */
|
||||||
if ((S->Flags & SF_VAR) == 0) {
|
if ((S->Flags & SF_VAR) == 0) {
|
||||||
Error ("Symbol '%m%p' is already defined", GetSymName (S));
|
Error ("Symbol '%m%p' is already defined", GetSymName (S));
|
||||||
|
if (CollCount (&S->DefLines) > 0) {
|
||||||
|
PNotification (GetSourcePos (CollAt(&S->DefLines, 0)),
|
||||||
|
"The symbol was previously defined here");
|
||||||
|
}
|
||||||
S->Flags |= SF_MULTDEF;
|
S->Flags |= SF_MULTDEF;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user