mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-04 08:20:12 +08:00
vla: Fix check for vla used by autoconf
1) recursive types have no storage anymore, so a static int (*p)[x]; declaration is just fine 2) since somewhen VT_VLA doesn't imply VT_ARRAY anymore, so we now need to check VLA in at least one place before checking test_lvalue. ((2) should probably be cleaned up again so that VLA does again imply ARRAY)
This commit is contained in:
parent
76b88e22a4
commit
fa25630ce4
5
tccgen.c
5
tccgen.c
@ -5018,7 +5018,8 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td)
|
||||
expect("identifier");
|
||||
*v = 0;
|
||||
}
|
||||
post_type(post, ad, storage, td & ~(TYPE_DIRECT|TYPE_ABSTRACT));
|
||||
post_type(post, ad, post != ret ? 0 : storage,
|
||||
td & ~(TYPE_DIRECT|TYPE_ABSTRACT));
|
||||
parse_attribute(ad);
|
||||
type->t |= storage;
|
||||
return ret;
|
||||
@ -5437,7 +5438,7 @@ ST_FUNC void unary(void)
|
||||
there and in function calls. */
|
||||
/* arrays can also be used although they are not lvalues */
|
||||
if ((vtop->type.t & VT_BTYPE) != VT_FUNC &&
|
||||
!(vtop->type.t & VT_ARRAY))
|
||||
!(vtop->type.t & (VT_ARRAY | VT_VLA)))
|
||||
test_lvalue();
|
||||
if (vtop->sym)
|
||||
vtop->sym->a.addrtaken = 1;
|
||||
|
@ -2979,6 +2979,7 @@ void c99_vla_test_2(int d, int h, int w)
|
||||
int x, y, z;
|
||||
int (*arr)[h][w] = malloc(sizeof(int) * d*h*w);
|
||||
int c = 1;
|
||||
static int (*starr)[h][w];
|
||||
|
||||
printf("Test C99 VLA 6 (pointer)\n");
|
||||
|
||||
@ -2998,13 +2999,15 @@ void c99_vla_test_2(int d, int h, int w)
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
starr = &arr[1];
|
||||
printf(" sizes : %d %d %d\n"
|
||||
" pdiff : %d %d\n"
|
||||
" tests : %d %d\n",
|
||||
" tests : %d %d %d\n",
|
||||
sizeof (*arr), sizeof (*arr)[0], sizeof (*arr)[0][0],
|
||||
arr + 2 - arr, *arr + 3 - *arr,
|
||||
0 == sizeof (*arr + 1) - sizeof arr,
|
||||
0 == sizeof sizeof *arr - sizeof arr
|
||||
0 == sizeof sizeof *arr - sizeof arr,
|
||||
starr[0][2][3] == arr[1][2][3]
|
||||
);
|
||||
free (arr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user