From f6c9db92697efcb8bafca1812d700fb60d1c8f12 Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Sun, 25 Nov 2018 03:48:45 +0700 Subject: [PATCH] __emit: Properly display error messages on type mismatch for arguments of type 'label' --- source/compiler/sc1.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 7e6b920..0421db4 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -6330,13 +6330,29 @@ static void SC_FASTCALL emit_param_label(emit_outval *p) goto invalid_token; /* fallthrough */ case tSYMBOL: - sym=fetchlab(str); + sym=findloc(str); + if (sym==NULL) + sym=findglb(str,sSTATEVAR); + if (sym!=NULL) { + markusage(sym,(sym->ident==iFUNCTN || sym->ident==iREFFUNC) ? uREAD : (uREAD | uWRITTEN)); + if (sym->ident!=iLABEL) { + if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) + tok=((sym->usage & uNATIVE)!=0) ? teNATIVE : teFUNCTN; + else if (sym->ident==iCONSTEXPR) + tok=teNUMERIC; + else + tok=(sym->vclass==sLOCAL) ? teLOCAL : teDATA; + goto invalid_token; + } /* if */ + } else { + sym=fetchlab(str); + } /* if */ sym->usage|=uREAD; p->value.ucell=(ucell)sym->addr; break; default: invalid_token: - emit_invalid_token(tSYMBOL,tok); + emit_invalid_token(tLABEL,tok); } }