mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
Some fixes and cleanups
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
tcc.h, tccgen.c: Add and use IS_BT_ARRAY tccpp.c: free memory when size is 0 in realloc code tccdbg.c: move common code to seperate function remove_type_info
This commit is contained in:
parent
edcd228214
commit
19589288cb
1
tcc.h
1
tcc.h
@ -1098,6 +1098,7 @@ struct filespec {
|
|||||||
|
|
||||||
/* base type is array (from typedef/typeof) */
|
/* base type is array (from typedef/typeof) */
|
||||||
#define VT_BT_ARRAY (6 << VT_STRUCT_SHIFT)
|
#define VT_BT_ARRAY (6 << VT_STRUCT_SHIFT)
|
||||||
|
#define IS_BT_ARRAY(t) ((t & VT_STRUCT_MASK) == VT_BT_ARRAY)
|
||||||
|
|
||||||
/* general: set/get the pseudo-bitfield value for bit-mask M */
|
/* general: set/get the pseudo-bitfield value for bit-mask M */
|
||||||
#define BFVAL(M,N) ((unsigned)((M) & ~((M) << 1)) * (N))
|
#define BFVAL(M,N) ((unsigned)((M) & ~((M) << 1)) * (N))
|
||||||
|
|||||||
30
tccdbg.c
30
tccdbg.c
@ -1769,6 +1769,16 @@ static int stabs_struct_find(TCCState *s1, Sym *t, int *p_id)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int remove_type_info(int type)
|
||||||
|
{
|
||||||
|
type &= ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE | VT_VLA);
|
||||||
|
if ((type & VT_BTYPE) != VT_BYTE)
|
||||||
|
type &= ~VT_DEFSIGN;
|
||||||
|
if (!(type & VT_BITFIELD) && (type & VT_STRUCT_MASK) > VT_ENUM)
|
||||||
|
type &= ~VT_STRUCT_MASK;
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result)
|
static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@ -1778,11 +1788,7 @@ static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result)
|
|||||||
CString str;
|
CString str;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
type = t->type.t & ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE | VT_VLA);
|
type = remove_type_info (t->type.t);
|
||||||
if ((type & VT_BTYPE) != VT_BYTE)
|
|
||||||
type &= ~VT_DEFSIGN;
|
|
||||||
if (!(type & VT_BITFIELD) && (type & VT_STRUCT_MASK) > VT_ENUM)
|
|
||||||
type &= ~VT_STRUCT_MASK;
|
|
||||||
if (type == VT_PTR || type == (VT_PTR | VT_ARRAY))
|
if (type == VT_PTR || type == (VT_PTR | VT_ARRAY))
|
||||||
n++, t = t->type.ref;
|
n++, t = t->type.ref;
|
||||||
else
|
else
|
||||||
@ -1861,9 +1867,7 @@ static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result)
|
|||||||
cstr_printf (result, "%d=", ++debug_next_type);
|
cstr_printf (result, "%d=", ++debug_next_type);
|
||||||
t = s;
|
t = s;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
type = t->type.t & ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE | VT_VLA);
|
type = remove_type_info (t->type.t);
|
||||||
if ((type & VT_BTYPE) != VT_BYTE)
|
|
||||||
type &= ~VT_DEFSIGN;
|
|
||||||
if (type == VT_PTR)
|
if (type == VT_PTR)
|
||||||
cstr_printf (result, "%d=*", ++debug_next_type);
|
cstr_printf (result, "%d=*", ++debug_next_type);
|
||||||
else if (type == (VT_PTR | VT_ARRAY))
|
else if (type == (VT_PTR | VT_ARRAY))
|
||||||
@ -1901,11 +1905,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s)
|
|||||||
if (new_file)
|
if (new_file)
|
||||||
put_new_file(s1);
|
put_new_file(s1);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
type = t->type.t & ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE | VT_VLA);
|
type = remove_type_info (t->type.t);
|
||||||
if ((type & VT_BTYPE) != VT_BYTE)
|
|
||||||
type &= ~VT_DEFSIGN;
|
|
||||||
if (!(type & VT_BITFIELD) && (type & VT_STRUCT_MASK) > VT_ENUM)
|
|
||||||
type &= ~VT_STRUCT_MASK;
|
|
||||||
if (type == VT_PTR || type == (VT_PTR | VT_ARRAY))
|
if (type == VT_PTR || type == (VT_PTR | VT_ARRAY))
|
||||||
t = t->type.ref;
|
t = t->type.ref;
|
||||||
else
|
else
|
||||||
@ -2052,9 +2052,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s)
|
|||||||
e = NULL;
|
e = NULL;
|
||||||
t = s;
|
t = s;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
type = t->type.t & ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE | VT_VLA);
|
type = remove_type_info (t->type.t);
|
||||||
if ((type & VT_BTYPE) != VT_BYTE)
|
|
||||||
type &= ~VT_DEFSIGN;
|
|
||||||
if (type == VT_PTR) {
|
if (type == VT_PTR) {
|
||||||
i = dwarf_info_section->data_offset;
|
i = dwarf_info_section->data_offset;
|
||||||
if (retval == debug_type)
|
if (retval == debug_type)
|
||||||
|
|||||||
2
tccgen.c
2
tccgen.c
@ -8204,7 +8204,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
|
|||||||
we will overwrite the unknown size by the real one for
|
we will overwrite the unknown size by the real one for
|
||||||
this decl. We need to unshare the ref symbol holding
|
this decl. We need to unshare the ref symbol holding
|
||||||
that size. */
|
that size. */
|
||||||
if (type->t & VT_BT_ARRAY)
|
if (IS_BT_ARRAY(type->t))
|
||||||
type->ref = sym_push(SYM_FIELD, &type->ref->type, 0, type->ref->c);
|
type->ref = sym_push(SYM_FIELD, &type->ref->type, 0, type->ref->c);
|
||||||
p.flex_array_ref = type->ref;
|
p.flex_array_ref = type->ref;
|
||||||
|
|
||||||
|
|||||||
5
tccpp.c
5
tccpp.c
@ -159,6 +159,7 @@ static void *tcc_realloc_impl(void *p, unsigned size)
|
|||||||
PP_ALLOC_INSERT(alloc);
|
PP_ALLOC_INSERT(alloc);
|
||||||
return alloc + 1;
|
return alloc + 1;
|
||||||
}
|
}
|
||||||
|
tcc_free(alloc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -372,8 +373,10 @@ tail_call:
|
|||||||
PP_ALLOC_INSERT(alloc);
|
PP_ALLOC_INSERT(alloc);
|
||||||
ret = alloc + 1;
|
ret = alloc + 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
tcc_free(alloc);
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef TAL_INFO
|
#ifdef TAL_INFO
|
||||||
al->nb_missed++;
|
al->nb_missed++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user