From 5fe4480b0ecf7a26724ce8ae8817a30fd43afb5a Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Sun, 29 Sep 2019 15:05:41 +0700 Subject: [PATCH] Ignore state specifications on old-style forward declarations --- source/compiler/sc1.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 85dafe7..143bf28 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -3246,8 +3246,6 @@ static int getstates(const char *funcname) static void attachstatelist(symbol *sym, int state_id) { assert(sym!=NULL); - if ((sym->usage & uDEFINE)!=0 && (sym->states==NULL || state_id==0)) - error(21,sym->name); /* function already defined, either without states or the current definition has no states */ if (state_id!=0) { /* add the state list id */ @@ -3947,7 +3945,6 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc state_id=getstates(symbolname); if (state_id>0 && (opertok!=0 || strcmp(symbolname,uMAINFUNC)==0)) error(82); /* operators may not have states, main() may neither */ - attachstatelist(sym,state_id); pc_deprecate=bck_deprecate; pc_attributes=bck_attributes; if (matchtoken(t__PRAGMA)) @@ -3959,9 +3956,12 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc sym->usage|=uFORWARD; if (!sc_needsemicolon) error(218); /* old style prototypes used with optional semicolons */ + if (state_id!=0) + error(231); /* state specification on forward declaration is ignored */ delete_symbols(&loctab,0,TRUE,TRUE); /* prototype is done; forget everything */ return TRUE; } /* if */ + attachstatelist(sym,state_id); /* so it is not a prototype, proceed */ /* if this is a function that is not referred to (this can only be detected * in the second stage), shut code generation off */ @@ -3970,6 +3970,8 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc cidx=code_idx; glbdecl=glb_declared; } /* if */ + if ((sym->usage & uDEFINE)!=0 && (sym->states==NULL || state_id==0)) + error(21,sym->name); /* function already defined, either without states or the current definition has no states */ if ((sym->flags & flagDEPRECATED)!=0 && fpublic) { char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; error(234,symbolname,ptr); /* deprecated (definitely a public function) */