Show errors for methods that are unused. (bug 6183)

This commit is contained in:
David Anderson 2014-07-12 10:28:29 -07:00
parent 9e1fef9775
commit 5dd5b5131b
7 changed files with 32 additions and 3 deletions

View File

@ -87,7 +87,7 @@ public Action Command_Play(int client, int args)
}
char target_name[MAX_TARGET_LENGTH];
char target_list[MAXPLAYERS], target_count;
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
if ((target_count = ProcessTargetString(

View File

@ -924,6 +924,7 @@ SC_VDECL int indent_nowarn; /* skip warning "217 loose indentation" */
SC_VDECL int sc_tabsize; /* number of spaces that a TAB represents */
SC_VDECL short sc_allowtags; /* allow/detect tagnames in lex() */
SC_VDECL int sc_status; /* read/write status */
SC_VDECL int sc_err_status; /* TRUE if errors should be generated even if sc_status = SKIP */
SC_VDECL int sc_rationaltag; /* tag for rational numbers */
SC_VDECL int rational_digits; /* number of fractional digits */
SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */

View File

@ -5261,13 +5261,20 @@ static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstati
return TRUE;
} /* if */
/* 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 */
if (sc_status==statWRITE && (sym->usage & uREAD)==0 && !fpublic) {
sc_status=statSKIP;
cidx=code_idx;
glbdecl=glb_declared;
sc_status=statSKIP;
// If this is a method, output errors even if it's unused.
if (thistag && *thistag != -1)
sc_err_status = TRUE;
} /* if */
if ((sym->flags & flgDEPRECATED) != 0 && (sym->usage & uSTOCK) == 0) {
char *ptr= (sym->documentation!=NULL) ? sym->documentation : "";
error(234, decl->name, ptr); /* deprecated (probably a public function) */
@ -5371,6 +5378,7 @@ static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstati
sc_status=statWRITE;
code_idx=cidx;
glb_declared=glbdecl;
sc_err_status=FALSE;
} /* if */
if (symp)
*symp = sym;

View File

@ -86,8 +86,13 @@ static short lastfile;
* the error reporting is enabled only in the second pass (and only when
* actually producing output). Fatal errors may never be ignored.
*/
if ((errflag || sc_status!=statWRITE) && (number<160 || number>=200))
int is_fatal = (number < 160 || number > 200);
if (errflag && is_fatal)
return 0;
if (sc_status != statWRITE && is_fatal) {
if (!sc_err_status)
return 0;
}
/* also check for disabled warnings */
if (number>=200) {

View File

@ -83,6 +83,7 @@ SC_VDEFINE int indent_nowarn=FALSE;/* skip warning "217 loose indentation" */
SC_VDEFINE int sc_tabsize=8; /* number of spaces that a TAB represents */
SC_VDEFINE short sc_allowtags=TRUE; /* allow/detect tagnames in lex() */
SC_VDEFINE int sc_status; /* read/write status */
SC_VDEFINE int sc_err_status;
SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */
SC_VDEFINE int rational_digits=0; /* number of fractional digits */
SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */

View File

@ -0,0 +1,13 @@
methodmap Duck
{
public void MyFunc()
{
// this will compile fine until this function is used elsewhere in code
ThisFuncDoesntExist();
}
};
public OnPluginStart()
{
}

View File

@ -0,0 +1 @@
(6) : error 017: undefined symbol "ThisFuncDoesntExist"