Compiler: Add a flag for warnings-as-errors
This commit is contained in:
parent
ae2699ca98
commit
e7c7313f77
|
@ -52,7 +52,7 @@
|
||||||
void extern __attribute__((visibility("default"))) EXCOMPILER(int argc, char **argv)
|
void extern __attribute__((visibility("default"))) EXCOMPILER(int argc, char **argv)
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
pc_compile(argc, argv);
|
pc_compile(argc, argv);
|
||||||
}
|
}
|
||||||
#endif /* PAWNC_DLL */
|
#endif /* PAWNC_DLL */
|
||||||
|
|
||||||
|
@ -112,8 +112,16 @@ static char *prefix[3]={ "error", "fatal error", "warning" };
|
||||||
|
|
||||||
if (number!=0) {
|
if (number!=0) {
|
||||||
char *pre;
|
char *pre;
|
||||||
|
int idx;
|
||||||
|
|
||||||
pre=prefix[number/100];
|
if (number < 100 || (number >= 200 && sc_warnings_are_errors))
|
||||||
|
idx = 0;
|
||||||
|
else if (number < 200)
|
||||||
|
idx = 1;
|
||||||
|
else
|
||||||
|
idx = 2;
|
||||||
|
|
||||||
|
pre=prefix[idx];
|
||||||
if (firstline>=0)
|
if (firstline>=0)
|
||||||
pc_printf("%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
|
pc_printf("%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
|
||||||
else
|
else
|
||||||
|
|
|
@ -798,6 +798,7 @@ SC_VDECL int rational_digits; /* number of fractional digits */
|
||||||
SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */
|
SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */
|
||||||
SC_VDECL short sc_is_utf8; /* is this source file in UTF-8 encoding */
|
SC_VDECL short sc_is_utf8; /* is this source file in UTF-8 encoding */
|
||||||
SC_VDECL char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */
|
SC_VDECL char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */
|
||||||
|
SC_VDECL int sc_warnings_are_errors;
|
||||||
|
|
||||||
SC_VDECL constvalue sc_automaton_tab; /* automaton table */
|
SC_VDECL constvalue sc_automaton_tab; /* automaton table */
|
||||||
SC_VDECL constvalue sc_state_tab; /* state table */
|
SC_VDECL constvalue sc_state_tab; /* state table */
|
||||||
|
|
|
@ -1052,6 +1052,9 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
|
||||||
strncpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */
|
strncpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */
|
||||||
ename[_MAX_PATH-1]='\0';
|
ename[_MAX_PATH-1]='\0';
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
sc_warnings_are_errors = 1;
|
||||||
|
break;
|
||||||
#if defined __WIN32__ || defined _WIN32 || defined _Windows
|
#if defined __WIN32__ || defined _WIN32 || defined _Windows
|
||||||
case 'H':
|
case 'H':
|
||||||
hwndFinish=(HWND)atoi(option_value(ptr));
|
hwndFinish=(HWND)atoi(option_value(ptr));
|
||||||
|
@ -1399,6 +1402,7 @@ static void about(void)
|
||||||
pc_printf(" -t<num> TAB indent size (in character positions, default=%d)\n",sc_tabsize);
|
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(" -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(" -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(" -X<num> abstract machine size limit in bytes\n");
|
||||||
pc_printf(" -\\ use '\\' for escape characters\n");
|
pc_printf(" -\\ use '\\' for escape characters\n");
|
||||||
pc_printf(" -^ use '^' for escape characters\n");
|
pc_printf(" -^ use '^' for escape characters\n");
|
||||||
|
|
|
@ -75,6 +75,9 @@ static short lastfile;
|
||||||
char *msg,*pre,*filename;
|
char *msg,*pre,*filename;
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char string[128];
|
char string[128];
|
||||||
|
int is_warning;
|
||||||
|
|
||||||
|
is_warning = (number >= 200 && !sc_warnings_are_errors);
|
||||||
|
|
||||||
/* errflag is reset on each semicolon.
|
/* errflag is reset on each semicolon.
|
||||||
* In a two-pass compiler, an error should not be reported twice. Therefore
|
* In a two-pass compiler, an error should not be reported twice. Therefore
|
||||||
|
@ -103,8 +106,13 @@ static short lastfile;
|
||||||
errnum++; /* a fatal error also counts as an error */
|
errnum++; /* a fatal error also counts as an error */
|
||||||
} else {
|
} else {
|
||||||
msg=warnmsg[number-200];
|
msg=warnmsg[number-200];
|
||||||
pre=prefix[2];
|
if (sc_warnings_are_errors) {
|
||||||
warnnum++;
|
pre=prefix[0];
|
||||||
|
errnum++;
|
||||||
|
} else {
|
||||||
|
pre=prefix[2];
|
||||||
|
warnnum++;
|
||||||
|
}
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
strexpand(string,(unsigned char *)msg,sizeof string,SCPACK_TABLE);
|
strexpand(string,(unsigned char *)msg,sizeof string,SCPACK_TABLE);
|
||||||
|
@ -164,7 +172,7 @@ static short lastfile;
|
||||||
errorcount=0;
|
errorcount=0;
|
||||||
lastline=fline;
|
lastline=fline;
|
||||||
lastfile=fcurrent;
|
lastfile=fcurrent;
|
||||||
if (number<200)
|
if (!is_warning)
|
||||||
errorcount++;
|
errorcount++;
|
||||||
if (errorcount>=3)
|
if (errorcount>=3)
|
||||||
error(107); /* too many error/warning messages on one line */
|
error(107); /* too many error/warning messages on one line */
|
||||||
|
|
|
@ -87,6 +87,7 @@ SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */
|
||||||
SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */
|
SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */
|
||||||
SC_VDEFINE char *pc_deprecate = NULL;/* if non-null, mark next declaration as deprecated */
|
SC_VDEFINE char *pc_deprecate = NULL;/* if non-null, mark next declaration as deprecated */
|
||||||
SC_VDEFINE int sc_showincludes=0; /* show include files */
|
SC_VDEFINE int sc_showincludes=0; /* show include files */
|
||||||
|
SC_VDEFINE int sc_warnings_are_errors=0;
|
||||||
|
|
||||||
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
|
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
|
||||||
SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */
|
SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user