fixed a bug where determinate 1D arrays would not have correct sizeof() -- REALLY hacky fix :(

fixed local arrays asserting on more than two dimensions with the last dimension being indeterminate

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40516
This commit is contained in:
David Anderson 2007-02-17 04:37:47 +00:00
parent 3f1051e83b
commit 314f3401c8
3 changed files with 20 additions and 3 deletions

View File

@ -823,6 +823,7 @@ SC_VDECL int pc_optimize; /* (peephole) optimization level */
SC_VDECL int pc_memflags; /* special flags for the stack/heap usage */
SC_VDECL int pc_functag; /* global function tag */
SC_VDECL int pc_tag_string; /* global string tag */
SC_VDECL int glbstringread; /* last global string read */
SC_VDECL constvalue sc_automaton_tab; /* automaton table */
SC_VDECL constvalue sc_state_tab; /* state table */

View File

@ -170,6 +170,7 @@ static int *wqptr; /* pointer to next entry */
static HWND hwndFinish = 0;
#endif
SC_VDECL int glbstringread = 0;
char g_tmpfile[_MAX_PATH] = {0};
/* "main" of the compiler
@ -2044,6 +2045,9 @@ static void declglb(char *firstname,int firsttag,int fpublic,int fstatic,int fst
} /* if */
assert(litidx==0); /* literal queue should be empty (again) */
initials(ident,tag,&size,dim,numdim,enumroot);/* stores values in the literal queue */
if (tag == pc_tag_string && (numdim == 1) && !dim[numdim-1]) {
slength = glbstringread;
}
assert(size>=litidx);
if (numdim==1)
dim[0]=(int)size;
@ -2209,6 +2213,7 @@ static int declloc(int fstatic)
do {
ident=iVARIABLE;
size=1;
slength=0;
numdim=0; /* no dimensions */
tag=pc_addtag(NULL);
if (lex(&val,&str)!=tSYMBOL) /* read in (new) token */
@ -2304,7 +2309,12 @@ static int declloc(int fstatic)
sc_alignnext=FALSE;
} /* if */
cur_lit=litidx; /* save current index in the literal table */
if (numdim && !dim[numdim-1])
size = 0;
initials(ident,tag,&size,dim,numdim,enumroot);
if (tag == pc_tag_string && (numdim == 1) && !dim[numdim-1]) {
slength = glbstringread;
}
if (size==0)
return ident; /* error message already given */
if (numdim==1)

View File

@ -1798,6 +1798,7 @@ static const unsigned char *packedstring(const unsigned char *lptr,int flags)
i=0; /* start at least significant byte */
val=0;
glbstringread=1;
while (*lptr!='\"' && *lptr!='\0') {
if (*lptr=='\a') { /* ignore '\a' (which was inserted at a line concatenation) */
lptr++;
@ -1807,6 +1808,7 @@ static const unsigned char *packedstring(const unsigned char *lptr,int flags)
if (c>=(ucell)(1 << sCHARBITS))
error(43); /* character constant exceeds range */
val |= (c << 8*i);
glbstringread++;
if (i==sizeof(ucell)-(sCHARBITS/8)) {
litadd(val);
val=0;
@ -2821,10 +2823,14 @@ SC_FUNC symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int
for (level=0; level<numdim; level++) {
top=addsym(name,addr,ident,vclass,tag,uDEFINE);
top->dim.array.length=dim[level];
if (tag == pc_tag_string && level == numdim - 1)
top->dim.array.slength=slength;
else
if (tag == pc_tag_string && level == numdim - 1) {
if (slength == 0)
top->dim.array.length=dim[level] * sizeof(cell);
else
top->dim.array.slength=slength;
} else {
top->dim.array.slength=0;
}
top->dim.array.level=(short)(numdim-level-1);
top->x.tags.index=idxtag[level];
top->parent=parent;