Merge remote-tracking branch 'yashas/i117-fix' into master

This commit is contained in:
Zeex 2017-05-01 10:40:23 +06:00
commit 9109958fd1

View File

@ -2521,7 +2521,7 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
constvalue *enumroot,int *errorfound) constvalue *enumroot,int *errorfound)
{ {
cell dsize,totalsize; cell dsize,totalsize;
int idx,idx_ellips,vidx; int idx,idx_ellips,vidx,do_insert;
int abortparse; int abortparse;
int curlit; int curlit;
cell *prev1=NULL,*prev2=NULL; cell *prev1=NULL,*prev2=NULL;
@ -2532,6 +2532,12 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
assert(errorfound!=NULL && *errorfound==FALSE); assert(errorfound!=NULL && *errorfound==FALSE);
totalsize=0; totalsize=0;
needtoken('{'); needtoken('{');
for (do_insert=0,idx=0; idx<=cur; idx++) {
if (dim[idx]==0) {
do_insert=TRUE;
break;
} /* if */
} /* for */
for (idx=0,abortparse=FALSE; !abortparse; idx++) { for (idx=0,abortparse=FALSE; !abortparse; idx++) {
/* In case the major dimension is zero, we need to store the offset /* In case the major dimension is zero, we need to store the offset
* to the newly detected sub-array into the indirection table; i.e. * to the newly detected sub-array into the indirection table; i.e.
@ -2541,7 +2547,7 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
* necessary at this point to reserve space for an extra cell in the * necessary at this point to reserve space for an extra cell in the
* indirection vector. * indirection vector.
*/ */
if (dim[cur]==0) { if (do_insert) {
litinsert(0,startlit); litinsert(0,startlit);
} else if (idx>=dim[cur]) { } else if (idx>=dim[cur]) {
error(18); /* initialization data exceeds array size */ error(18); /* initialization data exceeds array size */