Merge pull request #256 from alliedmodders/bug6302
Don't special case hierarchy-free enumeration constants when used as array indices. (bug 6302)
This commit is contained in:
commit
0bb2dc32af
@ -2227,7 +2227,11 @@ restart:
|
|||||||
* from the field and save the size of the field too.
|
* from the field and save the size of the field too.
|
||||||
*/
|
*/
|
||||||
assert(lval2.sym==NULL || lval2.sym->dim.array.level==0);
|
assert(lval2.sym==NULL || lval2.sym->dim.array.level==0);
|
||||||
if (lval2.sym!=NULL && lval2.sym->dim.array.length>0 && sym->dim.array.level==0) {
|
if (lval2.sym &&
|
||||||
|
lval2.sym->parent &&
|
||||||
|
lval2.sym->dim.array.length > 0 &&
|
||||||
|
sym->dim.array.level==0)
|
||||||
|
{
|
||||||
lval1->tag=lval2.sym->x.tags.index;
|
lval1->tag=lval2.sym->x.tags.index;
|
||||||
lval1->constval=lval2.sym->dim.array.length;
|
lval1->constval=lval2.sym->dim.array.length;
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -2280,8 +2284,11 @@ restart:
|
|||||||
* from the field and save the size of the field too. Otherwise, the
|
* from the field and save the size of the field too. Otherwise, the
|
||||||
* tag is the one from the array symbol.
|
* tag is the one from the array symbol.
|
||||||
*/
|
*/
|
||||||
if (lval2.ident==iCONSTEXPR && lval2.sym!=NULL
|
if (lval2.ident==iCONSTEXPR &&
|
||||||
&& lval2.sym->dim.array.length>0 && sym->dim.array.level==0)
|
lval2.sym &&
|
||||||
|
lval2.sym->parent &&
|
||||||
|
lval2.sym->dim.array.length > 0 &&
|
||||||
|
sym->dim.array.level == 0)
|
||||||
{
|
{
|
||||||
lval1->tag=lval2.sym->x.tags.index;
|
lval1->tag=lval2.sym->x.tags.index;
|
||||||
lval1->constval=lval2.sym->dim.array.length;
|
lval1->constval=lval2.sym->dim.array.length;
|
||||||
@ -2310,15 +2317,17 @@ restart:
|
|||||||
lval1->constval=0;
|
lval1->constval=0;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
/* a cell in an array is an lvalue, a character in an array is not
|
||||||
|
* always a *valid* lvalue */
|
||||||
|
lvalue = TRUE;
|
||||||
|
|
||||||
// If there's a call/fetch coming up, keep parsing.
|
// If there's a call/fetch coming up, keep parsing.
|
||||||
if (matchtoken('.')) {
|
if (matchtoken('.')) {
|
||||||
lexpush();
|
lexpush();
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a cell in an array is an lvalue, a character in an array is not
|
return lvalue;
|
||||||
* always a *valid* lvalue */
|
|
||||||
return TRUE;
|
|
||||||
} else { /* tok=='(' -> function(...) */
|
} else { /* tok=='(' -> function(...) */
|
||||||
svalue thisval;
|
svalue thisval;
|
||||||
thisval.val = *lval1;
|
thisval.val = *lval1;
|
||||||
|
Loading…
Reference in New Issue
Block a user