Fix error when static/stock/public constant used as array size
Fixes #70 --------- test code -------- native printf(const format[], ...); static const a = 1; static stock const b = 2; stock const c = 3; public const d = 4; main() { static const e = 5; new aa[a]; new ab[b]; new ac[c]; new ad[d]; new ae[e]; printf("%d", sizeof(aa), aa); printf("%d", sizeof(ab), ab); printf("%d", sizeof(ac), ac); printf("%d", sizeof(ad), ad); printf("%d", sizeof(ae), ae); } ----- end of test code -----
This commit is contained in:
parent
1cca8af0d2
commit
39828f23f2
@ -1860,10 +1860,15 @@ static void declfuncvar(int fpublic,int fstatic,int fstock,int fconst)
|
|||||||
/* only variables can be "const" or both "public" and "stock" */
|
/* only variables can be "const" or both "public" and "stock" */
|
||||||
invalidfunc= fconst || (fpublic && fstock);
|
invalidfunc= fconst || (fpublic && fstock);
|
||||||
if (invalidfunc || !newfunc(name,tag,fpublic,fstatic,fstock)) {
|
if (invalidfunc || !newfunc(name,tag,fpublic,fstatic,fstock)) {
|
||||||
/* if not a function, try a global variable */
|
/* if not a function, try a global constant/variable */
|
||||||
|
if (fconst) {
|
||||||
|
lexpush();
|
||||||
|
decl_const(sGLOBAL);
|
||||||
|
} else {
|
||||||
declglb(name,tag,fpublic,fstatic,fstock,fconst);
|
declglb(name,tag,fpublic,fstatic,fstock,fconst);
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
} /* if */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* declglb - declare global symbols
|
/* declglb - declare global symbols
|
||||||
@ -4948,8 +4953,14 @@ static void statement(int *lastindent,int allow_decl)
|
|||||||
break;
|
break;
|
||||||
case tSTATIC:
|
case tSTATIC:
|
||||||
if (allow_decl) {
|
if (allow_decl) {
|
||||||
|
tok=lex(&val,&st);
|
||||||
|
if (tok==tCONST) {
|
||||||
|
decl_const(sSTATIC);
|
||||||
|
} else {
|
||||||
|
lexpush();
|
||||||
declloc(TRUE);
|
declloc(TRUE);
|
||||||
lastst=tNEW;
|
lastst=tNEW;
|
||||||
|
} /* if */
|
||||||
} else {
|
} else {
|
||||||
error(3); /* declaration only valid in a block */
|
error(3); /* declaration only valid in a block */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user