Unified · Split
| @@ -76,6 +76,7 @@ static void parse_expr_type(CType *type); · 75 unmodified lines | |||
| 76 | static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only); | 76 | static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only); |
| 77 | static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr); | 77 | static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr); |
| 78 | static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope); | 78 | static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope); |
| 79 | static int decl0(int l, int is_for_loop_init); | ||
| 79 | static void expr_eq(void); | 80 | static void expr_eq(void); |
| 80 | static void unary_type(CType *type); | 81 | static void unary_type(CType *type); |
| 81 | static int is_compatible_parameter_types(CType *type1, CType *type2); | 82 | static int is_compatible_parameter_types(CType *type1, CType *type2); |
| @@ -4379,8 +4380,12 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 4297 unmodified lines | |||
| 4379 | next(); | 4380 | next(); |
| 4380 | skip('('); | 4381 | skip('('); |
| 4381 | if (tok != ';') { | 4382 | if (tok != ';') { |
| 4382 | gexpr(); | 4383 | /* c99 for-loop init decl? */ |
| 4383 | vpop(); | 4384 | if (!decl0(VT_LOCAL, 1)) { |
| 4385 | /* no, regular for-loop init expr */ | ||
| 4386 | gexpr(); | ||
| 4387 | vpop(); | ||
| 4388 | } | ||
| 4384 | } | 4389 | } |
| 4385 | skip(';'); | 4390 | skip(';'); |
| 4386 | d = ind; | 4391 | d = ind; |
| @@ -5406,7 +5411,7 @@ ST_FUNC void gen_inline_functions(void) · 1019 unmodified lines | |||
| 5406 | } | 5411 | } |
| 5407 | 5412 | ||
| 5408 | /* 'l' is VT_LOCAL or VT_CONST to define default storage type */ | 5413 | /* 'l' is VT_LOCAL or VT_CONST to define default storage type */ |
| 5409 | ST_FUNC void decl(int l) | 5414 | static int decl0(int l, int is_for_loop_init) |
| 5410 | { | 5415 | { |
| 5411 | int v, has_init, r; | 5416 | int v, has_init, r; |
| 5412 | CType type, btype; | 5417 | CType type, btype; |
| @@ -5415,6 +5420,8 @@ ST_FUNC void decl(int l) · 2 unmodified lines | |||
| 5415 | 5420 | ||
| 5416 | while (1) { | 5421 | while (1) { |
| 5417 | if (!parse_btype(&btype, &ad)) { | 5422 | if (!parse_btype(&btype, &ad)) { |
| 5423 | if (is_for_loop_init) | ||
| 5424 | return 0; | ||
| 5418 | /* skip redundant ';' */ | 5425 | /* skip redundant ';' */ |
| 5419 | /* XXX: find more elegant solution */ | 5426 | /* XXX: find more elegant solution */ |
| 5420 | if (tok == ';') { | 5427 | if (tok == ';') { |
| @@ -5629,6 +5636,8 @@ ST_FUNC void decl(int l) · 208 unmodified lines | |||
| 5629 | } | 5636 | } |
| 5630 | } | 5637 | } |
| 5631 | if (tok != ',') { | 5638 | if (tok != ',') { |
| 5639 | if (is_for_loop_init) | ||
| 5640 | return 1; | ||
| 5632 | skip(';'); | 5641 | skip(';'); |
| 5633 | break; | 5642 | break; |
| 5634 | } | 5643 | } |
| @@ -5636,4 +5645,10 @@ ST_FUNC void decl(int l) · 1 unmodified line | |||
| 5636 | } | 5645 | } |
| 5637 | } | 5646 | } |
| 5638 | } | 5647 | } |
| 5648 | return 0; | ||
| 5649 | } | ||
| 5650 | |||
| 5651 | ST_FUNC void decl(int l) | ||
| 5652 | { | ||
| 5653 | decl0(l, 0); | ||
| 5639 | } | 5654 | } |