From 5ee186223f1c59f41e8f486145f457401bc12658 Mon Sep 17 00:00:00 2001 From: VVWVV Date: Fri, 27 Jan 2017 18:30:01 +0300 Subject: [PATCH] Fix the compiler crash with #emit Signed-off-by: VVWVV --- source/compiler/sc2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index 7eecd3e..8b48cd2 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -1318,6 +1318,8 @@ static int command(void) error(17,str); /* undefined symbol */ } else { if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) { + int count; + if ((sym->usage & uNATIVE)!=0) { /* reserve a SYSREQ id if called for the first time */ if (sc_status==statWRITE && (sym->usage & uREAD)==0 && sym->addr>=0) @@ -1333,7 +1335,11 @@ static int command(void) /* mark function as "used" */ /* do NOT mark it as written as that has a different meaning for * functions (marks them as "should return a value") */ - markusage(sym,uREAD); + + for (count=0; countnumrefers && curfunc->refer[count]; count++) + /* nothing */; + if (count!=0 || (curfunc->usage & uPUBLIC)!=0) + markusage(sym,uREAD); } else { outval(sym->addr,FALSE); /* mark symbol as "used", unknown whether for read or write */