aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-07-13 17:39:15 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:08 +0100
commite034853b38907440142107eb689c5dd6c6621fca (patch)
tree858d1cd53633cd82b2203e802e80f37ed5a87415 /tccgen.c
parentb7e0b693a65793a5aeee51cf9fa58638376c6f06 (diff)
downloadtinycc-e034853b38907440142107eb689c5dd6c6621fca.tar.gz
tinycc-e034853b38907440142107eb689c5dd6c6621fca.tar.bz2
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).
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tccgen.c b/tccgen.c
index c006f71..6d72ab9 100644
--- a/tccgen.c
+++ b/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
{