Prevent declaring arrays that the compiler is too buggy to handle (bug 4977, r=fyren).
This commit is contained in:
parent
66d27d6ac5
commit
a02ff01d84
@ -2711,6 +2711,23 @@ static void initials2(int ident,int tag,cell *size,int dim[],int numdim,
|
|||||||
eq_match_override = matchtoken('=');
|
eq_match_override = matchtoken('=');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (numdim > 2) {
|
||||||
|
int d, hasEmpty = 0;
|
||||||
|
for (d = 0; d < numdim; d++) {
|
||||||
|
if (dim[d] == 0)
|
||||||
|
hasEmpty++;
|
||||||
|
}
|
||||||
|
/* Work around ambug 4977 where indirection vectors are computed wrong. */
|
||||||
|
if (hasEmpty && hasEmpty < numdim-1 && dim[numdim-1]) {
|
||||||
|
error(101);
|
||||||
|
/* This will assert with something like [2][][256] from a separate bug.
|
||||||
|
* To prevent this assert, automatically wipe the rest of the dims.
|
||||||
|
*/
|
||||||
|
for (d = 0; d < numdim - 1; d++)
|
||||||
|
dim[d] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!eq_match_override) {
|
if (!eq_match_override) {
|
||||||
assert(ident!=iARRAY || numdim>0);
|
assert(ident!=iARRAY || numdim>0);
|
||||||
if (ident==iARRAY && dim[numdim-1]==0) {
|
if (ident==iARRAY && dim[numdim-1]==0) {
|
||||||
|
@ -74,7 +74,6 @@ static int lastline,errorcount;
|
|||||||
static short lastfile;
|
static short lastfile;
|
||||||
char *msg,*pre;
|
char *msg,*pre;
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char string[128];
|
|
||||||
|
|
||||||
/* 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
|
||||||
@ -107,8 +106,6 @@ static short lastfile;
|
|||||||
warnnum++;
|
warnnum++;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
strexpand(string,(unsigned char *)msg,sizeof string,SCPACK_TABLE);
|
|
||||||
|
|
||||||
assert(errstart<=fline);
|
assert(errstart<=fline);
|
||||||
if (errline>0)
|
if (errline>0)
|
||||||
errstart=errline;
|
errstart=errline;
|
||||||
@ -118,7 +115,7 @@ static short lastfile;
|
|||||||
va_start(argptr,number);
|
va_start(argptr,number);
|
||||||
if (strlen(errfname)==0) {
|
if (strlen(errfname)==0) {
|
||||||
int start= (errstart==errline) ? -1 : errstart;
|
int start= (errstart==errline) ? -1 : errstart;
|
||||||
if (pc_error(number,string,inpfname,start,errline,argptr)) {
|
if (pc_error(number,msg,inpfname,start,errline,argptr)) {
|
||||||
if (outf!=NULL) {
|
if (outf!=NULL) {
|
||||||
pc_closeasm(outf,TRUE);
|
pc_closeasm(outf,TRUE);
|
||||||
outf=NULL;
|
outf=NULL;
|
||||||
@ -132,7 +129,7 @@ static short lastfile;
|
|||||||
fprintf(fp,"%s(%d -- %d) : %s %03d: ",inpfname,errstart,errline,pre,number);
|
fprintf(fp,"%s(%d -- %d) : %s %03d: ",inpfname,errstart,errline,pre,number);
|
||||||
else
|
else
|
||||||
fprintf(fp,"%s(%d) : %s %03d: ",inpfname,errline,pre,number);
|
fprintf(fp,"%s(%d) : %s %03d: ",inpfname,errline,pre,number);
|
||||||
vfprintf(fp,string,argptr);
|
vfprintf(fp,msg,argptr);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
@ -38,7 +38,7 @@ unsigned char errstr_table[][2] = {
|
|||||||
/*-*SCPACK end of pair table, do not change or remove this line */
|
/*-*SCPACK end of pair table, do not change or remove this line */
|
||||||
|
|
||||||
static char *errmsg[] = {
|
static char *errmsg[] = {
|
||||||
#ifdef SCPACK
|
#if 1
|
||||||
/*001*/ "expected token: \"%s\", but found \"%s\"\n",
|
/*001*/ "expected token: \"%s\", but found \"%s\"\n",
|
||||||
/*002*/ "only a single statement (or expression) can follow each \"case\"\n",
|
/*002*/ "only a single statement (or expression) can follow each \"case\"\n",
|
||||||
/*003*/ "declaration of a local variable must appear in a compound block\n",
|
/*003*/ "declaration of a local variable must appear in a compound block\n",
|
||||||
@ -138,7 +138,8 @@ static char *errmsg[] = {
|
|||||||
/*097*/ "symbol \"%s\" does not have a matching type\n",
|
/*097*/ "symbol \"%s\" does not have a matching type\n",
|
||||||
/*098*/ "struct requires unique struct name\n",
|
/*098*/ "struct requires unique struct name\n",
|
||||||
/*099*/ "member \"%s\" appears more than once in struct \"%s\"\n",
|
/*099*/ "member \"%s\" appears more than once in struct \"%s\"\n",
|
||||||
/*100*/ "function prototypes do not match\n"
|
/*100*/ "function prototypes do not match\n",
|
||||||
|
/*101*/ "specify either all dimensions or only the last dimension\n"
|
||||||
#else
|
#else
|
||||||
"\271pect\236\305k\212:\231\320bu\202fo\217\207\215\012",
|
"\271pect\236\305k\212:\231\320bu\202fo\217\207\215\012",
|
||||||
"\201l\224\251s\203g\362\317e\234\202(\260\374\201) c\352f\241\345w ea\261 \042c\361e\042\012",
|
"\201l\224\251s\203g\362\317e\234\202(\260\374\201) c\352f\241\345w ea\261 \042c\361e\042\012",
|
||||||
@ -244,7 +245,7 @@ static char *errmsg[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static char *fatalmsg[] = {
|
static char *fatalmsg[] = {
|
||||||
#ifdef SCPACK
|
#if 1
|
||||||
/*120*/ "cannot read from file: \"%s\"\n",
|
/*120*/ "cannot read from file: \"%s\"\n",
|
||||||
/*121*/ "cannot write to file: \"%s\"\n",
|
/*121*/ "cannot write to file: \"%s\"\n",
|
||||||
/*122*/ "table overflow: \"%s\"\n",
|
/*122*/ "table overflow: \"%s\"\n",
|
||||||
@ -280,7 +281,7 @@ static char *fatalmsg[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static char *warnmsg[] = {
|
static char *warnmsg[] = {
|
||||||
#ifdef SCPACK
|
#if 1
|
||||||
/*200*/ "symbol \"%s\" is truncated to %d characters\n",
|
/*200*/ "symbol \"%s\" is truncated to %d characters\n",
|
||||||
/*201*/ "redefinition of constant/macro (symbol \"%s\")\n",
|
/*201*/ "redefinition of constant/macro (symbol \"%s\")\n",
|
||||||
/*202*/ "number of arguments does not match definition\n",
|
/*202*/ "number of arguments does not match definition\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user