diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 9603610..ae00669 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) */ diff --git a/source/compiler/tests/warning_231.meta b/source/compiler/tests/warning_231.meta new file mode 100644 index 0000000..1e107c3 --- /dev/null +++ b/source/compiler/tests/warning_231.meta @@ -0,0 +1,7 @@ +{ + 'test_type': 'output_check', + 'errors': """ +warning_231.pwn(3) : warning 231: state specification on forward declaration is ignored +warning_231.pwn(6) : warning 231: state specification on forward declaration is ignored +""" +} diff --git a/source/compiler/tests/warning_231.pwn b/source/compiler/tests/warning_231.pwn new file mode 100644 index 0000000..1df19a1 --- /dev/null +++ b/source/compiler/tests/warning_231.pwn @@ -0,0 +1,9 @@ +#pragma option -;+ + +forward Func() ; // warning 231: state specification on forward declaration is ignored +public Func() {} + +public Func() ; // warning 231: state specification on forward declaration is ignored +public Func() {} + +main(){}