From 06183b37ae8f81fa60a5e301e8c60e1573954b3c Mon Sep 17 00:00:00 2001 From: Y_Less Date: Fri, 27 Mar 2020 14:33:25 +0000 Subject: [PATCH 1/4] Use `pragma deprecated` message in error 4: ```pawn #pragma deprecated - use "Test2". forward Test(); stock Test2() { } main() { Test(); } ``` --- source/compiler/sc1.c | 3 ++- source/compiler/sc3.c | 6 ++++-- source/compiler/sc5.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 90eaaa7..88d2c0b 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -5010,8 +5010,9 @@ static void destructsymbols(symbol *root,int level) if ((opsym->usage & uMISSING)!=0 || (opsym->usage & uPROTOTYPED)==0) { char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ funcdisplayname(symname,opsym->name); + char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; if ((opsym->usage & uMISSING)!=0) - error(4,symname); /* function not defined */ + error(4,symname,ptr); /* function not defined */ if ((opsym->usage & uPROTOTYPED)==0) error(71,symname); /* operator must be declared before use */ } /* if */ diff --git a/source/compiler/sc3.c b/source/compiler/sc3.c index 1185bcb..cf04eab 100644 --- a/source/compiler/sc3.c +++ b/source/compiler/sc3.c @@ -195,8 +195,9 @@ static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; if ((sym->usage & uMISSING)!=0 || (sym->usage & uPROTOTYPED)==0) { char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ funcdisplayname(symname,sym->name); + char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; if ((sym->usage & uMISSING)!=0) - error(4,symname); /* function not defined */ + error(4,symname,ptr); /* function not defined */ if ((sym->usage & uPROTOTYPED)==0) error(71,symname); /* operator must be declared before use */ } /* if */ @@ -1880,7 +1881,8 @@ restart: } else if ((sym->usage & uMISSING)!=0) { char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ funcdisplayname(symname,sym->name); - error(4,symname); /* function not defined */ + char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; + error(4,symname,ptr); /* function not defined */ } /* if */ callfunction(sym,lval1,TRUE); return FALSE; /* result of function call is no lvalue */ diff --git a/source/compiler/sc5.c b/source/compiler/sc5.c index df567f9..ec2d9cb 100644 --- a/source/compiler/sc5.c +++ b/source/compiler/sc5.c @@ -43,7 +43,7 @@ static char *errmsg[] = { /*001*/ "expected token: \"%s\", but found \"%s\"\n", /*002*/ "only a single statement (or expression) can follow each \"case\"\n", /*003*/ "declaration of a local variable must appear in a compound block\n", -/*004*/ "function \"%s\" is not implemented\n", +/*004*/ "function \"%s\" is not implemented %s\n", /*005*/ "function may not have arguments\n", /*006*/ "must be assigned to an array\n", /*007*/ "operator cannot be redefined\n", From e74b8bb282721484b06c6beac708916eaa3701dc Mon Sep 17 00:00:00 2001 From: Y_Less Date: Fri, 27 Mar 2020 18:36:07 +0000 Subject: [PATCH 2/4] Move declarations. --- source/compiler/sc3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/compiler/sc3.c b/source/compiler/sc3.c index cf04eab..d304dde 100644 --- a/source/compiler/sc3.c +++ b/source/compiler/sc3.c @@ -194,8 +194,8 @@ static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; /* check existance and the proper declaration of this function */ if ((sym->usage & uMISSING)!=0 || (sym->usage & uPROTOTYPED)==0) { char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,sym->name); char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; + funcdisplayname(symname,sym->name); if ((sym->usage & uMISSING)!=0) error(4,symname,ptr); /* function not defined */ if ((sym->usage & uPROTOTYPED)==0) @@ -1880,8 +1880,8 @@ restart: } /* if */ } else if ((sym->usage & uMISSING)!=0) { char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,sym->name); char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; + funcdisplayname(symname,sym->name); error(4,symname,ptr); /* function not defined */ } /* if */ callfunction(sym,lval1,TRUE); From 1488c26e475a6b57f0e8cbf7642b1452496b5227 Mon Sep 17 00:00:00 2001 From: Stanislav Gromov Date: Sat, 29 Aug 2020 20:57:31 +0800 Subject: [PATCH 3/4] Move the remaining declaration in sc1.c --- source/compiler/sc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 88d2c0b..280dec3 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -5009,8 +5009,8 @@ static void destructsymbols(symbol *root,int level) if ((opsym=findglb(symbolname,sGLOBAL))!=NULL) { if ((opsym->usage & uMISSING)!=0 || (opsym->usage & uPROTOTYPED)==0) { char symname[2*sNAMEMAX+16]; /* allow space for user defined operators */ - funcdisplayname(symname,opsym->name); char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; + funcdisplayname(symname,opsym->name); if ((opsym->usage & uMISSING)!=0) error(4,symname,ptr); /* function not defined */ if ((opsym->usage & uPROTOTYPED)==0) From 5bce87049b4a12ae8dd2efcec534a56e4f538e81 Mon Sep 17 00:00:00 2001 From: Stanislav Gromov Date: Sat, 29 Aug 2020 20:57:51 +0800 Subject: [PATCH 4/4] Add tests --- source/compiler/tests/gh_500.meta | 8 ++++++++ source/compiler/tests/gh_500.pwn | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 source/compiler/tests/gh_500.meta create mode 100644 source/compiler/tests/gh_500.pwn diff --git a/source/compiler/tests/gh_500.meta b/source/compiler/tests/gh_500.meta new file mode 100644 index 0000000..0ebab4f --- /dev/null +++ b/source/compiler/tests/gh_500.meta @@ -0,0 +1,8 @@ +{ + 'test_type': 'output_check', + 'errors': """ +gh_500.pwn(13) : error 004: function "Test1" is not implemented - use "Test4" +gh_500.pwn(14) : error 004: function "Test2" is not implemented +gh_500.pwn(15) : error 004: function "Test3" is not implemented +""" +} diff --git a/source/compiler/tests/gh_500.pwn b/source/compiler/tests/gh_500.pwn new file mode 100644 index 0000000..f3d0a87 --- /dev/null +++ b/source/compiler/tests/gh_500.pwn @@ -0,0 +1,16 @@ +#pragma deprecated - use "Test4" +forward Test1(); + +#pragma deprecated +forward Test2(); + +forward Test3(); + +stock Test4(){} + +main() +{ + Test1(); // error 004: function "Test1" is not implemented - use "Test4" + Test2(); // error 004: function "Test2" is not implemented + Test3(); // error 004: function "Test3" is not implemented +}