-E warnings as errors.

This commit is contained in:
Y_Less 2017-10-24 21:18:07 +02:00
parent 36d5eed854
commit f1da832ae9
4 changed files with 42 additions and 1 deletions

View File

@ -134,6 +134,9 @@ static char *prefix[3]={ "error", "fatal error", "warning" };
char *pre;
pre=prefix[number/100];
if (number>=200 && pc_geterrorwarnings()){
pre=prefix[0];
}
if (firstline>=0)
fprintf(stderr,"%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
else

View File

@ -485,6 +485,8 @@ int pc_addtag(char *name);
int pc_enablewarning(int number,int enable);
int pc_pushwarnings();
int pc_popwarnings();
void pc_seterrorwarnings(int enable);
int pc_geterrorwarnings();
/*
* Functions called from the compiler (to be implemented by you)

View File

@ -221,6 +221,9 @@ static char *prefix[3]={ "error", "fatal error", "warning" };
char *pre;
pre=prefix[number/100];
if (number>=200 && pc_geterrorwarnings()){
pre=prefix[0];
}
if (firstline>=0)
fprintf(stderr,"%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
else
@ -1159,6 +1162,19 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
if (sc_asmfile && verbosity>1)
verbosity=1;
break;
case 'E':
switch (*option_value(ptr)) {
case '+':
pc_seterrorwarnings(1);
break;
case '-':
pc_seterrorwarnings(0);
break;
default:
pc_seterrorwarnings(2);
break;
}
break;
case 'w':
i=(int)strtol(option_value(ptr),(char **)&ptr,10);
if (*ptr=='-')
@ -1450,6 +1466,7 @@ static void about(void)
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(" -Z[+/-] run in compatibility mode (default=%c)\n",pc_compat ? '+' : '-');
pc_printf(" -E[+/-] turn warnings in to errors\n");
pc_printf(" -\\ use '\\' for escape characters\n");
pc_printf(" -^ use '^' for escape characters\n");
pc_printf(" -;[+/-] require a semicolon to end each statement (default=%c)\n", sc_needsemicolon ? '+' : '-');

View File

@ -203,6 +203,7 @@ static struct s_warnstack {
static int errflag;
static int errstart; /* line number at which the instruction started */
static int errline; /* forced line number for the error message */
static int errwarn;
/* error
*
@ -249,6 +250,11 @@ static short lastfile;
msg=fatalmsg[number-100];
pre=prefix[1];
errnum++; /* a fatal error also counts as an error */
} else if (errwarn) {
msg=warnmsg[number-200];
pre=prefix[0];
errflag=TRUE;
errnum++;
} else {
msg=warnmsg[number-200];
pre=prefix[2];
@ -303,7 +309,7 @@ static short lastfile;
errorcount=0;
lastline=fline;
lastfile=fcurrent;
if (number<200)
if (number<200 || errwarn)
errorcount++;
if (errorcount>=3)
error(107); /* too many error/warning messages on one line */
@ -401,3 +407,16 @@ int pc_popwarnings()
return TRUE;
}
/* pc_seterrorwarnings()
* Make warnings errors (or not).
*/
void pc_seterrorwarnings(int enable)
{
errwarn = enable;
}
int pc_geterrorwarnings()
{
return errwarn;
}