Merge pull request #148 from alliedmodders/warnings-as-errors
Add a flag for warnings-as-errors.
This commit is contained in:
		
						commit
						40b1067ef7
					
				@ -74,7 +74,7 @@ static const char *prefix[3]={ "error", "fatal error", "warning" };
 | 
			
		||||
  if (number!=0) {
 | 
			
		||||
    int idx;
 | 
			
		||||
 | 
			
		||||
    if (number < 160)
 | 
			
		||||
    if (number < 160 || (number >= 200 && sc_warnings_are_errors))
 | 
			
		||||
      idx = 0;
 | 
			
		||||
    else if (number < 200)
 | 
			
		||||
      idx = 1;
 | 
			
		||||
 | 
			
		||||
@ -912,6 +912,7 @@ extern int pc_tag_nullfunc_t;   /* the null function type */
 | 
			
		||||
extern int pc_anytag;       /* global any tag */
 | 
			
		||||
extern int glbstringread;	  /* last global string read */
 | 
			
		||||
extern int sc_require_newdecls; /* only newdecls are allowed */
 | 
			
		||||
extern bool sc_warnings_are_errors;
 | 
			
		||||
 | 
			
		||||
extern constvalue sc_automaton_tab; /* automaton table */
 | 
			
		||||
extern constvalue sc_state_tab;     /* state table */
 | 
			
		||||
 | 
			
		||||
@ -944,6 +944,9 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
 | 
			
		||||
      case 'e':
 | 
			
		||||
        strlcpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */
 | 
			
		||||
        break;
 | 
			
		||||
      case 'E':
 | 
			
		||||
        sc_warnings_are_errors = true;
 | 
			
		||||
        break;
 | 
			
		||||
#if defined __WIN32__ || defined _WIN32 || defined _Windows
 | 
			
		||||
      case 'H':
 | 
			
		||||
        hwndFinish=(HWND)atoi(option_value(ptr));
 | 
			
		||||
@ -1312,6 +1315,7 @@ static void about(void)
 | 
			
		||||
    pc_printf("         -t<num>  TAB indent size (in character positions, default=%d)\n",sc_tabsize);
 | 
			
		||||
    pc_printf("         -v<num>  verbosity level; 0=quiet, 1=normal, 2=verbose (default=%d)\n",verbosity);
 | 
			
		||||
    pc_printf("         -w<num>  disable a specific warning by its number\n");
 | 
			
		||||
    pc_printf("         -E       treat warnings as errors\n");
 | 
			
		||||
    pc_printf("         -X<num>  abstract machine size limit in bytes\n");
 | 
			
		||||
    pc_printf("         -XD<num> abstract machine data/stack size limit in bytes\n");
 | 
			
		||||
    pc_printf("         -\\       use '\\' for escape characters\n");
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,4 @@
 | 
			
		||||
// vim: set ts=8 sts=2 sw=2 tw=99 et:
 | 
			
		||||
/*  Pawn compiler - Error message system
 | 
			
		||||
 *  In fact a very simple system, using only 'panic mode'.
 | 
			
		||||
 *
 | 
			
		||||
@ -81,6 +82,8 @@ static short lastfile;
 | 
			
		||||
  int errline = sErrLine;
 | 
			
		||||
  sErrLine = -1;
 | 
			
		||||
 | 
			
		||||
  bool is_warning = (number >= 200 && !sc_warnings_are_errors);
 | 
			
		||||
 | 
			
		||||
  /* errflag is reset on each semicolon.
 | 
			
		||||
   * In a two-pass compiler, an error should not be reported twice. Therefore
 | 
			
		||||
   * the error reporting is enabled only in the second pass (and only when
 | 
			
		||||
@ -113,8 +116,13 @@ static short lastfile;
 | 
			
		||||
    errnum++;           /* a fatal error also counts as an error */
 | 
			
		||||
  } else {
 | 
			
		||||
    msg=warnmsg[number-200];
 | 
			
		||||
    pre=prefix[2];
 | 
			
		||||
    warnnum++;
 | 
			
		||||
    if (sc_warnings_are_errors) {
 | 
			
		||||
      pre=prefix[0];
 | 
			
		||||
      errnum++;
 | 
			
		||||
    } else {
 | 
			
		||||
      pre=prefix[2];
 | 
			
		||||
      warnnum++;
 | 
			
		||||
    }
 | 
			
		||||
  } /* if */
 | 
			
		||||
 | 
			
		||||
  assert(errstart<=fline);
 | 
			
		||||
@ -164,7 +172,7 @@ static short lastfile;
 | 
			
		||||
    errorcount=0;
 | 
			
		||||
  lastline=fline;
 | 
			
		||||
  lastfile=fcurrent;
 | 
			
		||||
  if (number<200)
 | 
			
		||||
  if (!is_warning)
 | 
			
		||||
    errorcount++;
 | 
			
		||||
  if (errorcount>=3)
 | 
			
		||||
    error(167);         /* too many error/warning messages on one line */
 | 
			
		||||
 | 
			
		||||
@ -94,6 +94,7 @@ int pc_optimize=sOPTIMIZE_NOMACRO; /* (peephole) optimization level */
 | 
			
		||||
int pc_memflags=0;      /* special flags for the stack/heap usage */
 | 
			
		||||
int sc_showincludes=0;  /* show include files */
 | 
			
		||||
int sc_require_newdecls=0; /* Require new-style declarations */
 | 
			
		||||
bool sc_warnings_are_errors=false;
 | 
			
		||||
 | 
			
		||||
constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
 | 
			
		||||
constvalue sc_state_tab = { NULL, "", 0, 0};   /* state table */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user