1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 06:29:38 +00:00

Fix wrong line info sometimes output for macros: When macro parameters were

expanded, the line info came from the parameter replacement list, but was
marked as coming from the macro. Now parameter replacement lists don't change
the line info.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5051 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-06-13 08:53:41 +00:00
parent d1426aaa43
commit ff9841d7b5
5 changed files with 28 additions and 22 deletions

View File

@ -134,7 +134,7 @@ void InitLineInfo (void)
unsigned AllocLineInfoSlot (unsigned Type, unsigned Count)
int AllocLineInfoSlot (unsigned Type, unsigned Count)
/* Allocate a line info slot of the given type and return the slot index */
{
/* Grow the array if necessary */
@ -152,18 +152,18 @@ unsigned AllocLineInfoSlot (unsigned Type, unsigned Count)
CurLineInfo[UsedSlots].Info = 0;
/* Increment the count and return the index of the new slot */
return UsedSlots++;
return (int) UsedSlots++;
}
void FreeLineInfoSlot (unsigned Slot)
void FreeLineInfoSlot (int Slot)
/* Free the line info in the given slot. Note: Alloc/Free must be used in
* FIFO order.
*/
{
/* Check the parameter */
PRECONDITION (Slot == UsedSlots - 1);
PRECONDITION (Slot == (int) UsedSlots - 1);
/* Free the last entry */
CurLineInfo[Slot].Info = 0;
@ -172,7 +172,7 @@ void FreeLineInfoSlot (unsigned Slot)
void GenLineInfo (unsigned Slot, const FilePos* Pos)
void GenLineInfo (int Slot, const FilePos* Pos)
/* Generate a new line info in the given slot */
{
/* Get a pointer to the slot */
@ -190,7 +190,7 @@ void GenLineInfo (unsigned Slot, const FilePos* Pos)
void ClearLineInfo (unsigned Slot)
void ClearLineInfo (int Slot)
/* Clear the line info in the given slot */
{
/* Zero the pointer */

View File

@ -56,6 +56,7 @@
* standard line info. It is assumed to be always there.
*/
enum {
LI_SLOT_INV = -1, /* Use to mark invalid slots */
LI_SLOT_ASM = 0, /* Normal assembler source */
LI_SLOT_EXT = 1, /* Externally supplied line info */
};
@ -82,18 +83,18 @@ struct LineInfo {
void InitLineInfo (void);
/* Initialize the line infos */
unsigned AllocLineInfoSlot (unsigned Type, unsigned Count);
int AllocLineInfoSlot (unsigned Type, unsigned Count);
/* Allocate a line info slot of the given type and return the slot index */
void FreeLineInfoSlot (unsigned Slot);
void FreeLineInfoSlot (int Slot);
/* Free the line info in the given slot. Note: Alloc/Free must be used in
* FIFO order.
*/
void GenLineInfo (unsigned Slot, const FilePos* Pos);
void GenLineInfo (int Slot, const FilePos* Pos);
/* Generate a new line info in the given slot */
void ClearLineInfo (unsigned Slot);
void ClearLineInfo (int Slot);
/* Clear the line info in the given slot */
void GetFullLineInfo (Collection* LineInfos, unsigned IncUsage);
@ -150,3 +151,4 @@ void WriteLineInfos (void);

View File

@ -135,7 +135,7 @@ struct MacExp {
unsigned ParamCount; /* Number of actual parameters */
TokNode** Params; /* List of actual parameters */
TokNode* ParamExp; /* Node for expanding parameters */
unsigned LISlot; /* Slot for additional line infos */
int LISlot; /* Slot for additional line infos */
};
/* Maximum number of nested macro expansions */
@ -235,7 +235,7 @@ static void FreeIdDescList (IdDesc* ID)
/* Free a complete list of IdDesc structures */
{
while (ID) {
IdDesc* This = ID;
IdDesc* This = ID;
ID = ID->Next;
FreeIdDesc (This);
}
@ -656,8 +656,8 @@ static int MacExpand (void* Data)
*/
if (Mac->ParamExp) {
/* Ok, use token from parameter list */
TokSet (Mac->ParamExp, Mac->LISlot);
/* Ok, use token from parameter list, but don't use its line info */
TokSet (Mac->ParamExp, LI_SLOT_INV);
/* Set pointer to next token */
Mac->ParamExp = Mac->ParamExp->Next;

View File

@ -82,17 +82,20 @@ void FreeTokNode (TokNode* N)
void TokSet (TokNode* N, unsigned LineInfoSlot)
/* Set the scanner token from the given token node. The given line info slot
* is used to store the position of the token fed into the scanner.
void TokSet (TokNode* N, int LineInfoSlot)
/* Set the scanner token from the given token node. If the given line info
* slot is not LI_SLOT_INV, it is used to store the position of the token fed
* into the scanner.
*/
{
/* Set the values */
CopyToken (&CurTok, &N->T);
SB_Terminate (&CurTok.SVal);
/* Set the position */
GenLineInfo (LineInfoSlot, &CurTok.Pos);
/* Set the position if the slot is not invald */
if (LineInfoSlot != LI_SLOT_INV) {
GenLineInfo (LineInfoSlot, &CurTok.Pos);
}
}

View File

@ -95,9 +95,10 @@ TokNode* NewTokNode (void);
void FreeTokNode (TokNode* N);
/* Free the given token node */
void TokSet (TokNode* N, unsigned LineInfoSlot);
/* Set the scanner token from the given token node. The given line info slot
* is used to store the position of the token fed into the scanner.
void TokSet (TokNode* N, int LineInfoSlot);
/* Set the scanner token from the given token node. If the given line info
* slot is not LI_SLOT_INV, it is used to store the position of the token fed
* into the scanner.
*/
enum TC TokCmp (const TokNode* N);