From 00e3e00327352006b0b3b493680924d8181f18db Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Sat, 24 Nov 2018 23:19:55 +0700 Subject: [PATCH] __emit: Don't accept numeric constants for arguments of type 'data offset' --- source/compiler/sc1.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 365d486..64db1c0 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -6220,8 +6220,6 @@ static void SC_FASTCALL emit_param_data(emit_outval *p) p->type=eotNUMBER; tok=lex(&val,&str); switch (tok) { - case tNUMBER: - break; case tSYMBOL: sym=findloc(str); if (sym!=NULL) { @@ -6230,8 +6228,8 @@ static void SC_FASTCALL emit_param_data(emit_outval *p) tok=tLABEL; goto invalid_token; } /* if */ - if (sym->vclass!=sSTATIC && sym->ident!=iCONSTEXPR) { - tok=teLOCAL; + if (sym->vclass!=sSTATIC) { + tok=(sym->ident==iCONSTEXPR) ? teNUMERIC : teLOCAL; goto invalid_token; } /* if */ } else { @@ -6245,6 +6243,10 @@ static void SC_FASTCALL emit_param_data(emit_outval *p) tok=((sym->usage & uNATIVE)!=0) ? teNATIVE : teFUNCTN; goto invalid_token; } /* if */ + if (sym->ident==iCONSTEXPR) { + tok=teNUMERIC; + goto invalid_token; + } /* if */ } /* if */ val=sym->addr; break;