diff --git a/plugins/sounds.sp b/plugins/sounds.sp index 6838573e..a815eed2 100644 --- a/plugins/sounds.sp +++ b/plugins/sounds.sp @@ -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( diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 5c1af76c..38c68ac6 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -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() */ diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 2a90ee79..8282a890 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -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; diff --git a/sourcepawn/compiler/sc5.c b/sourcepawn/compiler/sc5.c index e5db4db0..faf8a979 100644 --- a/sourcepawn/compiler/sc5.c +++ b/sourcepawn/compiler/sc5.c @@ -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) { diff --git a/sourcepawn/compiler/scvars.c b/sourcepawn/compiler/scvars.c index c9a440be..a7b5b5f9 100644 --- a/sourcepawn/compiler/scvars.c +++ b/sourcepawn/compiler/scvars.c @@ -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() */ diff --git a/sourcepawn/compiler/tests/fail-methodmap-missing-method.sp b/sourcepawn/compiler/tests/fail-methodmap-missing-method.sp new file mode 100644 index 00000000..36ebdba5 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-methodmap-missing-method.sp @@ -0,0 +1,13 @@ +methodmap Duck +{ + public void MyFunc() + { + // this will compile fine until this function is used elsewhere in code + ThisFuncDoesntExist(); + } +}; + +public OnPluginStart() +{ +} + diff --git a/sourcepawn/compiler/tests/fail-methodmap-missing-method.txt b/sourcepawn/compiler/tests/fail-methodmap-missing-method.txt new file mode 100644 index 00000000..e68fb927 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-methodmap-missing-method.txt @@ -0,0 +1 @@ +(6) : error 017: undefined symbol "ThisFuncDoesntExist"