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 c6e15cdb..0c5c8471 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -927,6 +927,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 02b6baf5..94f14d9f 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -5252,13 +5252,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) */ @@ -5362,6 +5369,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..6b44e527 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 not_fatal = (number < 160 || number >= 200); + if (errflag && not_fatal) return 0; + if (sc_status != statWRITE && not_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"