mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-04 06:30:10 +08:00
A reverse of the commit 14745bdeb
because of the problems while compiling linux 2.4.26
A test program: /////////// typedef unsigned int __u32; static inline const __u32 __fswab32(__u32 x) { return ({ __u32 __tmp = (x) ; ___swab32(__tmp); }); } void func() { int aaa = 1; int snd_wnd = 2; int TCP_FLAG_ACK = 3; int pred_flags = (__builtin_constant_p((__u32) (((aaa << 26) | (__builtin_constant_p((__u32)((TCP_FLAG_ACK))) ? ({ __u32 __x = (((TCP_FLAG_ACK))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32(((TCP_FLAG_ACK)))) | snd_wnd))) ? ({ __u32 __x = ((((aaa << 26) | (__builtin_constant_p((__u32)((TCP_FLAG_ACK))) ? ({ __u32 __x = (((TCP_FLAG_ACK))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32(((TCP_FLAG_ACK)))) | snd_wnd))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32((((aaa << 26) | (__builtin_constant_p((__u32)((TCP_FLAG_ACK))) ? ({ __u32 __x = (((TCP_FLAG_ACK))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32(((TCP_FLAG_ACK)))) | snd_wnd)))); } //////////// error: ';' expected (got "(")
This commit is contained in:
parent
6fd4e5bace
commit
c45a8695eb
1
libtcc.c
1
libtcc.c
@ -786,6 +786,7 @@ static int tcc_compile(TCCState *s1)
|
||||
#endif
|
||||
|
||||
define_start = define_stack;
|
||||
nocode_wanted = 1;
|
||||
|
||||
if (setjmp(s1->error_jmp_buf) == 0) {
|
||||
s1->nb_errors = 0;
|
||||
|
33
tccgen.c
33
tccgen.c
@ -5661,7 +5661,9 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
|
||||
literals). It also simplifies local
|
||||
initializers handling */
|
||||
tok_str_new(&init_str);
|
||||
if ((size < 0 || flexible_array) && has_init) {
|
||||
if (size < 0 || (flexible_array && has_init)) {
|
||||
if (!has_init)
|
||||
tcc_error("unknown type size");
|
||||
/* get all init string */
|
||||
if (has_init == 2) {
|
||||
/* only get strings */
|
||||
@ -5700,19 +5702,11 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
|
||||
macro_ptr = init_str.str;
|
||||
next();
|
||||
|
||||
/* if still unknown size, error */
|
||||
size = type_size(type, &align);
|
||||
if (size < 0)
|
||||
tcc_error("unknown type size");
|
||||
}
|
||||
|
||||
/* if still unknown size, error */
|
||||
if (size < 0)
|
||||
tcc_error("unknown type size");
|
||||
|
||||
if (nocode_wanted) {
|
||||
//tcc_warning("nocode_wanted set for decl_initializer_alloc");
|
||||
vset(type, r, 0);
|
||||
goto no_alloc;
|
||||
}
|
||||
|
||||
if (flexible_array)
|
||||
size += flexible_array->type.ref->c * pointed_size(&flexible_array->type);
|
||||
/* take into account specified alignment if bigger */
|
||||
@ -5859,17 +5853,17 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
|
||||
}
|
||||
if (has_init || (type->t & VT_VLA)) {
|
||||
decl_initializer(type, sec, addr, 1, 0);
|
||||
/* restore parse state if needed */
|
||||
if (init_str.str) {
|
||||
tok_str_free(init_str.str);
|
||||
restore_parse_state(&saved_parse_state);
|
||||
}
|
||||
/* patch flexible array member size back to -1, */
|
||||
/* for possible subsequent similar declarations */
|
||||
if (flexible_array)
|
||||
flexible_array->type.ref->c = -1;
|
||||
}
|
||||
no_alloc:
|
||||
/* restore parse state if needed */
|
||||
if (init_str.str) {
|
||||
tok_str_free(init_str.str);
|
||||
restore_parse_state(&saved_parse_state);
|
||||
}
|
||||
no_alloc: ;
|
||||
}
|
||||
|
||||
static void put_func_debug(Sym *sym)
|
||||
@ -5941,6 +5935,8 @@ static void func_decl_list(Sym *func_sym)
|
||||
'cur_text_section' */
|
||||
static void gen_function(Sym *sym)
|
||||
{
|
||||
int saved_nocode_wanted = nocode_wanted;
|
||||
nocode_wanted = 0;
|
||||
ind = cur_text_section->data_offset;
|
||||
/* NOTE: we patch the symbol size later */
|
||||
put_extern_sym(sym, cur_text_section, ind, 0);
|
||||
@ -5996,6 +5992,7 @@ static void gen_function(Sym *sym)
|
||||
func_vt.t = VT_VOID; /* for safety */
|
||||
func_var = 0; /* for safety */
|
||||
ind = 0; /* for safety */
|
||||
nocode_wanted = saved_nocode_wanted;
|
||||
}
|
||||
|
||||
ST_FUNC void gen_inline_functions(void)
|
||||
|
Loading…
Reference in New Issue
Block a user