From: cuz Date: Wed, 15 Oct 2003 09:33:01 +0000 (+0000) Subject: Don't generate internal errors on duplicate labels X-Git-Tag: V2.12.0~1257 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e6a5b59b42b72dfb6b411f6cac21bd7c2d588ebf;p=cc65 Don't generate internal errors on duplicate labels git-svn-id: svn://svn.cc65.org/cc65/trunk@2524 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/codeseg.c b/src/cc65/codeseg.c index fede7ae62..eb2cb0679 100644 --- a/src/cc65/codeseg.c +++ b/src/cc65/codeseg.c @@ -6,9 +6,9 @@ /* */ /* */ /* */ -/* (C) 2001-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ +/* (C) 2001-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ /* */ @@ -183,41 +183,6 @@ static void CS_RemoveLabelFromHash (CodeSeg* S, CodeLabel* L) -static CodeLabel* CS_AddLabelInternal (CodeSeg* S, const char* Name, - void (*ErrorFunc) (const char*, ...)) -/* Add a code label for the next instruction to follow */ -{ - /* Calculate the hash from the name */ - unsigned Hash = HashStr (Name) % CS_LABEL_HASH_SIZE; - - /* Try to find the code label if it does already exist */ - CodeLabel* L = CS_FindLabel (S, Name, Hash); - - /* Did we find it? */ - if (L) { - /* We found it - be sure it does not already have an owner */ - if (L->Owner) { - ErrorFunc ("ASM label `%s' is already defined", Name); - } - } else { - /* Not found - create a new one */ - L = CS_NewCodeLabel (S, Name, Hash); - } - - /* Safety. This call is quite costly, but safety is better */ - if (CollIndex (&S->Labels, L) >= 0) { - ErrorFunc ("ASM label `%s' is already defined", Name); - } - - /* We do now have a valid label. Remember it for later */ - CollAppend (&S->Labels, L); - - /* Return the label */ - return L; -} - - - /*****************************************************************************/ /* Functions for parsing instructions */ /*****************************************************************************/ @@ -297,7 +262,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L) L = SkipSpace (L+1); /* Add the label */ - CS_AddLabelInternal (S, Mnemo, Error); + CS_AddLabel (S, Mnemo); /* If we have reached end of line, bail out, otherwise a mnemonic * may follow. @@ -422,7 +387,7 @@ static CodeEntry* ParseInsn (CodeSeg* S, LineInfo* LI, const char* L) AM = AM65_ZPX; } else { AM = AM65_ABSX; - } + } } else if (Reg == 'Y') { AM = AM65_ABSY; } else { @@ -783,7 +748,35 @@ int CS_RangeHasLabel (CodeSeg* S, unsigned Start, unsigned Count) CodeLabel* CS_AddLabel (CodeSeg* S, const char* Name) /* Add a code label for the next instruction to follow */ { - return CS_AddLabelInternal (S, Name, Internal); + /* Calculate the hash from the name */ + unsigned Hash = HashStr (Name) % CS_LABEL_HASH_SIZE; + + /* Try to find the code label if it does already exist */ + CodeLabel* L = CS_FindLabel (S, Name, Hash); + + /* Did we find it? */ + if (L) { + /* We found it - be sure it does not already have an owner */ + if (L->Owner) { + Error ("ASM label `%s' is already defined", Name); + return L; + } + } else { + /* Not found - create a new one */ + L = CS_NewCodeLabel (S, Name, Hash); + } + + /* Safety. This call is quite costly, but safety is better */ + if (CollIndex (&S->Labels, L) >= 0) { + Error ("ASM label `%s' is already defined", Name); + return L; + } + + /* We do now have a valid label. Remember it for later */ + CollAppend (&S->Labels, L); + + /* Return the label */ + return L; }