mirror of
https://github.com/TinyCC/tinycc.git
synced 2026-02-04 21:01:36 +00:00
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()"
This commit is contained in:
@@ -1517,7 +1517,7 @@ ST_FUNC void subst_asm_operand(CString *add_str,
|
||||
} else if (r & VT_LVAL) {
|
||||
reg = r & VT_VALMASK;
|
||||
if (reg >= VT_CONST)
|
||||
tcc_error("internal compiler error");
|
||||
tcc_internal_error("");
|
||||
snprintf(buf, sizeof(buf), "(%%%s)",
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
get_tok_str(TOK_ASM_rax + reg, NULL)
|
||||
@@ -1530,7 +1530,7 @@ ST_FUNC void subst_asm_operand(CString *add_str,
|
||||
/* register case */
|
||||
reg = r & VT_VALMASK;
|
||||
if (reg >= VT_CONST)
|
||||
tcc_error("internal compiler error");
|
||||
tcc_internal_error("");
|
||||
|
||||
/* choose register operand size */
|
||||
if ((sv->type.t & VT_BTYPE) == VT_BYTE ||
|
||||
|
||||
Reference in New Issue
Block a user