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
786786 #endif
787787
788788 define_start = define_stack;
789+ nocode_wanted = 1;
789790
790791 if (setjmp(s1->error_jmp_buf) == 0) {
791792 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
56615661 literals). It also simplifies local
56625662 initializers handling */
56635663 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");
56655667 /* get all init string */
56665668 if (has_init == 2) {
56675669 /* only get strings */
@@ -5700,19 +5702,11 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 32 unmodified lines
57005702 macro_ptr = init_str.str;
57015703 next();
57025704
5705+ /* if still unknown size, error */
57035706 size = type_size(type, &align);
5707+ if (size < 0)
5708+ tcc_error("unknown type size");
57045709 }
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−
57165710 if (flexible_array)
57175711 size += flexible_array->type.ref->c * pointed_size(&flexible_array->type);
57185712 /* 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
58595853 }
58605854 if (has_init || (type->t & VT_VLA)) {
58615855 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+ }
58625861 /* patch flexible array member size back to -1, */
58635862 /* for possible subsequent similar declarations */
58645863 if (flexible_array)
58655864 flexible_array->type.ref->c = -1;
58665865 }
5867−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− }
5866+ no_alloc: ;
58735867 }
58745868
58755869 static void put_func_debug(Sym *sym)
@@ -5941,6 +5935,8 @@ static void func_decl_list(Sym *func_sym) · 65 unmodified lines
59415935 'cur_text_section' */
59425936 static void gen_function(Sym *sym)
59435937 {
5938+ int saved_nocode_wanted = nocode_wanted;
5939+ nocode_wanted = 0;
59445940 ind = cur_text_section->data_offset;
59455941 /* NOTE: we patch the symbol size later */
59465942 put_extern_sym(sym, cur_text_section, ind, 0);
@@ -5996,6 +5992,7 @@ static void gen_function(Sym *sym) · 49 unmodified lines
59965992 func_vt.t = VT_VOID; /* for safety */
59975993 func_var = 0; /* for safety */
59985994 ind = 0; /* for safety */
5995+ nocode_wanted = saved_nocode_wanted;
59995996 }
60005997
60015998 ST_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