History

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 "(")

seyko committed 11 years ago

Commit c45a8691 parent 6fd4e5b2 files · +16 −18Browse files

Unified · Split

2 files
  1. libtcc.c +1 −0
  2. tccgen.c +15 −18
libtcc.c+1−0
@@ -786,6 +786,7 @@ static int tcc_compile(TCCState *s1) · 785 unmodified lines
786#endif786#endif
787 787
788 define_start = define_stack;788 define_start = define_stack;
789 nocode_wanted = 1;
789 790
790 if (setjmp(s1->error_jmp_buf) == 0) {791 if (setjmp(s1->error_jmp_buf) == 0) {
791 s1->nb_errors = 0;792 s1->nb_errors = 0;
tccgen.c+15−18
@@ -5661,7 +5661,9 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 5660 unmodified lines
5661 literals). It also simplifies local5661 literals). It also simplifies local
5662 initializers handling */5662 initializers handling */
5663 tok_str_new(&init_str);5663 tok_str_new(&init_str);
5664 if ((size < 0 || flexible_array) && has_init) {5664 if (size < 0 || (flexible_array && has_init)) {
5665 if (!has_init)
5666 tcc_error("unknown type size");
5665 /* get all init string */5667 /* get all init string */
5666 if (has_init == 2) {5668 if (has_init == 2) {
5667 /* only get strings */5669 /* only get strings */
@@ -5700,19 +5702,11 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 32 unmodified lines
5700 macro_ptr = init_str.str;5702 macro_ptr = init_str.str;
5701 next();5703 next();
5702 5704
5705 /* if still unknown size, error */
5703 size = type_size(type, &align);5706 size = type_size(type, &align);
5707 if (size < 0)
5708 tcc_error("unknown type size");
5704 }5709 }
5705
5706 /* if still unknown size, error */
5707 if (size < 0)
5708 tcc_error("unknown type size");
5709
5710 if (nocode_wanted) {
5711 //tcc_warning("nocode_wanted set for decl_initializer_alloc");
5712 vset(type, r, 0);
5713 goto no_alloc;
5714 }
5715
5716 if (flexible_array)5710 if (flexible_array)
5717 size += flexible_array->type.ref->c * pointed_size(&flexible_array->type);5711 size += flexible_array->type.ref->c * pointed_size(&flexible_array->type);
5718 /* take into account specified alignment if bigger */5712 /* take into account specified alignment if bigger */
@@ -5859,17 +5853,17 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 140 unmodified lines
5859 }5853 }
5860 if (has_init || (type->t & VT_VLA)) {5854 if (has_init || (type->t & VT_VLA)) {
5861 decl_initializer(type, sec, addr, 1, 0);5855 decl_initializer(type, sec, addr, 1, 0);
5856 /* restore parse state if needed */
5857 if (init_str.str) {
5858 tok_str_free(init_str.str);
5859 restore_parse_state(&saved_parse_state);
5860 }
5862 /* patch flexible array member size back to -1, */5861 /* patch flexible array member size back to -1, */
5863 /* for possible subsequent similar declarations */5862 /* for possible subsequent similar declarations */
5864 if (flexible_array)5863 if (flexible_array)
5865 flexible_array->type.ref->c = -1;5864 flexible_array->type.ref->c = -1;
5866 }5865 }
5867no_alloc:5866 no_alloc: ;
5868 /* restore parse state if needed */
5869 if (init_str.str) {
5870 tok_str_free(init_str.str);
5871 restore_parse_state(&saved_parse_state);
5872 }
5873}5867}
5874 5868
5875static void put_func_debug(Sym *sym)5869static void put_func_debug(Sym *sym)
@@ -5941,6 +5935,8 @@ static void func_decl_list(Sym *func_sym) · 65 unmodified lines
5941 'cur_text_section' */5935 'cur_text_section' */
5942static void gen_function(Sym *sym)5936static void gen_function(Sym *sym)
5943{5937{
5938 int saved_nocode_wanted = nocode_wanted;
5939 nocode_wanted = 0;
5944 ind = cur_text_section->data_offset;5940 ind = cur_text_section->data_offset;
5945 /* NOTE: we patch the symbol size later */5941 /* NOTE: we patch the symbol size later */
5946 put_extern_sym(sym, cur_text_section, ind, 0);5942 put_extern_sym(sym, cur_text_section, ind, 0);
@@ -5996,6 +5992,7 @@ static void gen_function(Sym *sym) · 49 unmodified lines
5996 func_vt.t = VT_VOID; /* for safety */5992 func_vt.t = VT_VOID; /* for safety */
5997 func_var = 0; /* for safety */5993 func_var = 0; /* for safety */
5998 ind = 0; /* for safety */5994 ind = 0; /* for safety */
5995 nocode_wanted = saved_nocode_wanted;
5999}5996}
6000 5997
6001ST_FUNC void gen_inline_functions(void)5998ST_FUNC void gen_inline_functions(void)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t