From 2ec21c5b7f5b875171b581380d4ee6ed5990b4ac Mon Sep 17 00:00:00 2001 From: laubzega Date: Sat, 29 Sep 2018 12:06:33 -0700 Subject: [PATCH] Fix non-goto jumps (i.e. inline assembly). --- src/cc65/goto.c | 2 +- src/cc65/symentry.h | 2 ++ src/cc65/symtab.c | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc65/goto.c b/src/cc65/goto.c index 3b1d243e7..ae9e6096d 100644 --- a/src/cc65/goto.c +++ b/src/cc65/goto.c @@ -61,7 +61,7 @@ void GotoStatement (void) } else { /* Add a new label symbol if we don't have one until now */ - SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF); + SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF | SC_GOTO); /* Jump to the label */ g_jump (Entry->V.L.Label); diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index 2dc731f35..e978274dc 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -98,6 +98,8 @@ struct LiteralPool; #define SC_HAVEATTR 0x10000U /* Symbol has attributes */ +#define SC_GOTO 0x20000U + diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 9a34de0dc..d76729cd8 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -701,7 +701,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) for (i = 0; i < CollCount (Entry->V.L.DefsOrRefs); i++) { DOR = CollAt (Entry->V.L.DefsOrRefs, i); - if ((DOR->Flags & SC_DEF) && (Flags & SC_REF)) { + if ((DOR->Flags & SC_DEF) && (Flags & SC_REF) && (Flags & SC_GOTO)) { /* We're processing a goto and here is its destination label. This means the difference between SP values is already known, so we simply emit the SP adjustment code. */ @@ -721,7 +721,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) } - if ((DOR->Flags & SC_REF) && (Flags & SC_DEF)) { + if ((DOR->Flags & SC_REF) && (DOR->Flags & SC_GOTO) && (Flags & SC_DEF)) { /* We're processing a label, let's update all gotos encountered so far */ g_defdatalabel (DOR->LateSP_Label); @@ -762,7 +762,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) } /* We are processing a goto, but the label has not yet been defined */ - if (!SymIsDef (Entry) && (Flags & SC_REF)) { + if (!SymIsDef (Entry) && (Flags & SC_REF) && (Flags & SC_GOTO)) { g_lateadjustSP (NewDOR->LateSP_Label); } -- 2.39.5