| @@ -5661,7 +5661,9 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 5660 unmodified lines |
| 5661 | literals). It also simplifies local | 5661 | 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 | } |
| 5867 | no_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 | |
| 5875 | static void put_func_debug(Sym *sym) | 5869 | static 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' */ |
| 5942 | static void gen_function(Sym *sym) | 5936 | static 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 | |
| 6001 | ST_FUNC void gen_inline_functions(void) | 5998 | ST_FUNC void gen_inline_functions(void) |