fixed an index bug on non-constant values
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40161
This commit is contained in:
parent
453f0db476
commit
edeb131e94
@ -1741,6 +1741,7 @@ static int hier1(value *lval1)
|
|||||||
char *st;
|
char *st;
|
||||||
char close;
|
char close;
|
||||||
symbol *sym;
|
symbol *sym;
|
||||||
|
int magic_string=0;
|
||||||
symbol dummysymbol,*cursym; /* for changing the index tags in case of enumerated pseudo-arrays */
|
symbol dummysymbol,*cursym; /* for changing the index tags in case of enumerated pseudo-arrays */
|
||||||
|
|
||||||
lvalue=primary(lval1);
|
lvalue=primary(lval1);
|
||||||
@ -1750,6 +1751,7 @@ restart:
|
|||||||
sym=cursym;
|
sym=cursym;
|
||||||
if (matchtoken('[') || matchtoken('{') || matchtoken('(')) {
|
if (matchtoken('[') || matchtoken('{') || matchtoken('(')) {
|
||||||
tok=tokeninfo(&val,&st); /* get token read by matchtoken() */
|
tok=tokeninfo(&val,&st); /* get token read by matchtoken() */
|
||||||
|
magic_string = (sym->tag == pc_tag_string && sym->dim.array.level == 0);
|
||||||
if (sym==NULL && symtok!=tSYMBOL) {
|
if (sym==NULL && symtok!=tSYMBOL) {
|
||||||
/* we do not have a valid symbol and we appear not to have read a valid
|
/* we do not have a valid symbol and we appear not to have read a valid
|
||||||
* symbol name (so it is unlikely that we would have read a name of an
|
* symbol name (so it is unlikely that we would have read a name of an
|
||||||
@ -1834,7 +1836,7 @@ restart:
|
|||||||
} else {
|
} else {
|
||||||
/* array index is not constant */
|
/* array index is not constant */
|
||||||
lval1->arrayidx=NULL; /* reset, so won't be checked */
|
lval1->arrayidx=NULL; /* reset, so won't be checked */
|
||||||
if (close==']') {
|
if (close==']' && !magic_string) {
|
||||||
if (sym->dim.array.length!=0)
|
if (sym->dim.array.length!=0)
|
||||||
ffbounds(sym->dim.array.length-1); /* run time check for array bounds */
|
ffbounds(sym->dim.array.length-1); /* run time check for array bounds */
|
||||||
cell2addr(); /* normal array index */
|
cell2addr(); /* normal array index */
|
||||||
@ -1845,7 +1847,7 @@ restart:
|
|||||||
} /* if */
|
} /* if */
|
||||||
popreg(sALT);
|
popreg(sALT);
|
||||||
ob_add(); /* base address was popped into secondary register */
|
ob_add(); /* base address was popped into secondary register */
|
||||||
if (close!=']')
|
if (close!=']' || magic_string)
|
||||||
charalign(); /* align character index into array */
|
charalign(); /* align character index into array */
|
||||||
} /* if */
|
} /* if */
|
||||||
/* the indexed item may be another array (multi-dimensional arrays) */
|
/* the indexed item may be another array (multi-dimensional arrays) */
|
||||||
|
Loading…
Reference in New Issue
Block a user