tccgen: flex arrays etc.
commit72b520e709d608f0450226bdfdc7b5bdb223aebf
authorgrischka <grischka>
Wed, 23 Sep 2020 10:03:59 +0000 (23 12:03 +0200)
committergrischka <grischka>
Sat, 3 Oct 2020 16:12:46 +0000 (3 18:12 +0200)
treee55ab6c005b64f5da02a18a9e660bc99eb299a90
parent40395511d7e3c53afe7774342bbd23fb2f91f16b
tccgen: flex arrays etc.

Fixes potential writes past the allocated space with mostly
illegal flex array initializers. (60_errors_and_warnings.c
:test_var_array)

In exchange suspicious precautions such as section_reserve
or checks with sec->data_allocated were removed.  (There is
an hard check 'init_assert()' for now but it's meant to be
just temporary)

Also, instead of filling holes, always memset(0) structures
& arrays on stack.  Sometimes more efficient, sometimes isn't.
At least we can omit putting null initializers.

About array range inititializers:  Reparsing tokens has a
small problem with sideeffects, for example

   int c = 0, dd[] = { [0 ... 1] = ++c, [2 ... 3] = ++c };

Also, instead of 'squeeze_multi_relocs()', delete pre-existing
relocations in advance. This works even if secondary initializers
don't even have relocations, as with
    [0 ... 7] = &stuff,
    [4] = NULL

Also, in tcc.h: new macro "tcc_internal_error()"
i386-asm.c
tcc.h
tccelf.c
tccgen.c
tccpp.c
tests/tests2/60_errors_and_warnings.c
tests/tests2/60_errors_and_warnings.expect
tests/tests2/90_struct-init.c
tests/tests2/90_struct-init.expect