Skip to content

Commit 85814e7

Browse files
committed
Merge remote-tracking branch 'remotes/Daniel-Cortez/fix-632' into dev
2 parents 685b691 + c9d2acb commit 85814e7

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

source/compiler/sc1.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,8 +3246,6 @@ static int getstates(const char *funcname)
32463246
static void attachstatelist(symbol *sym, int state_id)
32473247
{
32483248
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 */
32513249

32523250
if (state_id!=0) {
32533251
/* add the state list id */
@@ -3947,7 +3945,6 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
39473945
state_id=getstates(symbolname);
39483946
if (state_id>0 && (opertok!=0 || strcmp(symbolname,uMAINFUNC)==0))
39493947
error(82); /* operators may not have states, main() may neither */
3950-
attachstatelist(sym,state_id);
39513948
pc_deprecate=bck_deprecate;
39523949
pc_attributes=bck_attributes;
39533950
if (matchtoken(t__PRAGMA))
@@ -3959,9 +3956,12 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
39593956
sym->usage|=uFORWARD;
39603957
if (!sc_needsemicolon)
39613958
error(218); /* old style prototypes used with optional semicolons */
3959+
if (state_id!=0)
3960+
error(231); /* state specification on forward declaration is ignored */
39623961
delete_symbols(&loctab,0,TRUE,TRUE); /* prototype is done; forget everything */
39633962
return TRUE;
39643963
} /* if */
3964+
attachstatelist(sym,state_id);
39653965
/* so it is not a prototype, proceed */
39663966
/* if this is a function that is not referred to (this can only be detected
39673967
* 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
39703970
cidx=code_idx;
39713971
glbdecl=glb_declared;
39723972
} /* 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 */
39733975
if ((sym->flags & flagDEPRECATED)!=0 && fpublic) {
39743976
char *ptr= (sym->documentation!=NULL) ? sym->documentation : "";
39753977
error(234,symbolname,ptr); /* deprecated (definitely a public function) */
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
'test_type': 'output_check',
3+
'errors': """
4+
warning_231.pwn(3) : warning 231: state specification on forward declaration is ignored
5+
warning_231.pwn(6) : warning 231: state specification on forward declaration is ignored
6+
"""
7+
}

source/compiler/tests/warning_231.pwn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma option -;+
2+
3+
forward Func() <auto1:st1>; // warning 231: state specification on forward declaration is ignored
4+
public Func() <auto1:st1> {}
5+
6+
public Func() <auto1:st2>; // warning 231: state specification on forward declaration is ignored
7+
public Func() <auto1:st2> {}
8+
9+
main(){}

0 commit comments

Comments
 (0)