Merge pull request #91 from alliedmodders/bug-6183
Show errors for methods that are unused. (bug 6183)
This commit is contained in:
		
						commit
						2ea9ec50b5
					
				| @ -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( | ||||
|  | ||||
| @ -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() */ | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
| @ -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() */ | ||||
|  | ||||
							
								
								
									
										13
									
								
								sourcepawn/compiler/tests/fail-methodmap-missing-method.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								sourcepawn/compiler/tests/fail-methodmap-missing-method.sp
									
									
									
									
									
										Normal 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() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1 @@ | ||||
| (6) : error 017: undefined symbol "ThisFuncDoesntExist" | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user