Compiler: Improve sizeof return on array without specifiying the dimensions.
Imported from Pawn 3.1.3636. "When making an array without specifiying the dimensions, but where the element count at the lowest dimension is the same for all, the compiler now "counts" this size, rather than setting the lowest dimension as "variable length". An example for this situation is the declaration: new my_array[][] = { {1,0}, {2,1}, {3,1} } No dimensions are given, but the new compiler determines that the minor dimension is 2 (and the major dimension is 3). Previous compilers set the minor dimension to 0 --meaning "variable"."
This commit is contained in:
parent
cd189320e5
commit
c4b233d094
|
@ -2248,6 +2248,24 @@ static void initials(int ident,int tag,cell *size,int dim[],int numdim,
|
||||||
err++;
|
err++;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* for */
|
} /* for */
|
||||||
|
if (numdim>1 && dim[numdim-1]==0) {
|
||||||
|
/* also look whether, by any chance, all "counted" final dimensions are
|
||||||
|
* the same value; if so, we can store this
|
||||||
|
*/
|
||||||
|
constvalue *ld=lastdim.next;
|
||||||
|
int d,match;
|
||||||
|
for (d=0; d<dim[numdim-2]; d++) {
|
||||||
|
assert(ld!=NULL);
|
||||||
|
assert(strtol(ld->name,NULL,16)==d);
|
||||||
|
if (d==0)
|
||||||
|
match=ld->value;
|
||||||
|
else if (match!=ld->value)
|
||||||
|
break;
|
||||||
|
ld=ld->next;
|
||||||
|
} /* for */
|
||||||
|
if (d==dim[numdim-2])
|
||||||
|
dim[numdim-1]=match;
|
||||||
|
} /* if */
|
||||||
/* after all arrays have been initalized, we know the (major) dimensions
|
/* after all arrays have been initalized, we know the (major) dimensions
|
||||||
* of the array and we can properly adjust the indirection vectors
|
* of the array and we can properly adjust the indirection vectors
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user