@@ -3246,8 +3246,6 @@ static int getstates(const char *funcname)
3246
3246
static void attachstatelist (symbol * sym , int state_id )
3247
3247
{
3248
3248
assert (sym != NULL );
3249
- if ((sym -> usage & uDEFINE )!= 0 && (sym -> states == NULL || state_id == 0 ))
3250
- error (21 ,sym -> name ); /* function already defined, either without states or the current definition has no states */
3251
3249
3252
3250
if (state_id != 0 ) {
3253
3251
/* add the state list id */
@@ -3947,7 +3945,6 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
3947
3945
state_id = getstates (symbolname );
3948
3946
if (state_id > 0 && (opertok != 0 || strcmp (symbolname ,uMAINFUNC )== 0 ))
3949
3947
error (82 ); /* operators may not have states, main() may neither */
3950
- attachstatelist (sym ,state_id );
3951
3948
pc_deprecate = bck_deprecate ;
3952
3949
pc_attributes = bck_attributes ;
3953
3950
if (matchtoken (t__PRAGMA ))
@@ -3959,9 +3956,12 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
3959
3956
sym -> usage |=uFORWARD ;
3960
3957
if (!sc_needsemicolon )
3961
3958
error (218 ); /* old style prototypes used with optional semicolons */
3959
+ if (state_id != 0 )
3960
+ error (231 ); /* state specification on forward declaration is ignored */
3962
3961
delete_symbols (& loctab ,0 ,TRUE,TRUE); /* prototype is done; forget everything */
3963
3962
return TRUE;
3964
3963
} /* if */
3964
+ attachstatelist (sym ,state_id );
3965
3965
/* so it is not a prototype, proceed */
3966
3966
/* if this is a function that is not referred to (this can only be detected
3967
3967
* 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
3970
3970
cidx = code_idx ;
3971
3971
glbdecl = glb_declared ;
3972
3972
} /* if */
3973
+ if ((sym -> usage & uDEFINE )!= 0 && (sym -> states == NULL || state_id == 0 ))
3974
+ error (21 ,sym -> name ); /* function already defined, either without states or the current definition has no states */
3973
3975
if ((sym -> flags & flagDEPRECATED )!= 0 && fpublic ) {
3974
3976
char * ptr = (sym -> documentation != NULL ) ? sym -> documentation : "" ;
3975
3977
error (234 ,symbolname ,ptr ); /* deprecated (definitely a public function) */
0 commit comments