Fix parsing array typedefs of unknown size
This must compile:
typedef int arrtype1[];
arrtype1 sinit19 = {1};
arrtype1 sinit20 = {2,3};
and generate two arrays of one resp. two elements. Before the fix
the determined size of the first array was encoded in the type
directly, so sinit20 couldn't be parsed anymore (because arrtype1
was thought to be only one element long).
This commit is contained in:
8
tccgen.c
8
tccgen.c
@ -6657,6 +6657,14 @@ static int decl0(int l, int is_for_loop_init)
|
||||
}
|
||||
while (1) { /* iterate thru each declaration */
|
||||
type = btype;
|
||||
/* If the base type itself was an array type of unspecified
|
||||
size (like in 'typedef int arr[]; arr x = {1};') then
|
||||
we will overwrite the unknown size by the real one for
|
||||
this decl. We need to unshare the ref symbol holding
|
||||
that size. */
|
||||
if ((type.t & VT_ARRAY) && type.ref->c < 0) {
|
||||
type.ref = sym_push(SYM_FIELD, &type.ref->type, 0, type.ref->c);
|
||||
}
|
||||
type_decl(&type, &ad, &v, TYPE_DIRECT);
|
||||
#if 0
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user