Ignore state specifications on old-style forward declarations

This commit is contained in:
Daniel_Cortez 2019-09-29 15:05:41 +07:00 committed by Stanislav Gromov
parent c9ad518d52
commit 5fe4480b0e

View File

@ -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) */