handle arrays with a flexible member but no initializer
This commit is contained in:
2
tccgen.c
2
tccgen.c
@ -5146,7 +5146,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
|
|||||||
literals). It also simplifies local
|
literals). It also simplifies local
|
||||||
initializers handling */
|
initializers handling */
|
||||||
tok_str_new(&init_str);
|
tok_str_new(&init_str);
|
||||||
if (size < 0 || flexible_array) {
|
if (size < 0 || (flexible_array && has_init)) {
|
||||||
if (!has_init)
|
if (!has_init)
|
||||||
error("unknown type size");
|
error("unknown type size");
|
||||||
/* get all init string */
|
/* get all init string */
|
||||||
|
|||||||
@ -1301,6 +1301,8 @@ struct complexinit2 {
|
|||||||
int b[];
|
int b[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct complexinit2 cix20;
|
||||||
|
|
||||||
struct complexinit2 cix21 = {
|
struct complexinit2 cix21 = {
|
||||||
.a = 3000,
|
.a = 3000,
|
||||||
.b = { 3001, 3002, 3003 }
|
.b = { 3001, 3002, 3003 }
|
||||||
@ -1410,7 +1412,7 @@ void init_test(void)
|
|||||||
cix[0].b[1].a, cix[0].b[1].b,
|
cix[0].b[1].a, cix[0].b[1].b,
|
||||||
cix[0].b[2].a, cix[0].b[2].b);
|
cix[0].b[2].a, cix[0].b[2].b);
|
||||||
printf("cix2: %d %d\n", cix21.b[2], cix22.b[5]);
|
printf("cix2: %d %d\n", cix21.b[2], cix22.b[5]);
|
||||||
printf("sizeof cix21 %d, sizeof cix22 %d\n", sizeof cix21, sizeof cix22);
|
printf("sizeof cix20 %d, cix21 %d, sizeof cix22 %d\n", sizeof cix20, sizeof cix21, sizeof cix22);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user