Skip to content

-E warnings as errors. #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/compiler/libpawnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/compiler/sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=='-')
Expand Down Expand Up @@ -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 ? '+' : '-');
Expand Down
21 changes: 20 additions & 1 deletion source/compiler/sc5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}