History

fix cleanup with break and continue

fix cleanup

matthias committed 7 years ago

Commit 0d549461 parent d30bc6d1 file · +14 −12Browse files

Unified · Split

tccgen.c+14−12
@@ -94,7 +94,7 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td); · 93 unmodified lines
9494 static void parse_expr_type(CType *type);
9595 static void init_putv(CType *type, Section *sec, unsigned long c);
9696 static void decl_initializer(CType *type, Section *sec, unsigned long c, int flags);
97−static void block(int *bsym, int *csym, int is_expr);
97+static void block(int *bsym, Sym *bcl, int *csym, Sym *ccl, int is_expr);
9898 static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, int scope);
9999 static void decl(int l);
100100 static int decl0(int l, int is_for_loop_init, Sym *);
@@ -4891,7 +4891,7 @@ ST_FUNC void unary(void) · 4790 unmodified lines
48914891 as statement expressions can't ever be entered from the
48924892 outside, so any reactivation of code emission (from labels
48934893 or loop heads) can be disabled again after the end of it. */
4894− block(NULL, NULL, 1);
4894+ block(NULL, NULL, NULL, NULL, 1);
48954895 nocode_wanted = saved_nocode_wanted;
48964896 skip(')');
48974897 } else {
@@ -6083,7 +6083,7 @@ static void gcase(struct case_t **base, int len, int *bsym) · 1185 unmodified lines
60836083 }
60846084 }
60856085
6086−static void block(int *bsym, int *csym, int is_expr)
6086+static void block(int *bsym, Sym *bcl, int *csym, Sym *ccl, int is_expr)
60876087 {
60886088 int a, b, c, d, cond;
60896089 Sym *s;
@@ -6112,7 +6112,7 @@ static void block(int *bsym, int *csym, int is_expr) · 22 unmodified lines
61126112 a = gvtst(1, 0);
61136113 if (cond == 0)
61146114 nocode_wanted |= 0x20000000;
6115− block(bsym, csym, 0);
6115+ block(bsym, bcl, csym, ccl, 0);
61166116 if (cond != 1)
61176117 nocode_wanted = saved_nocode_wanted;
61186118 if (tok == TOK_ELSE) {
@@ -6121,7 +6121,7 @@ static void block(int *bsym, int *csym, int is_expr) · 2 unmodified lines
61216121 gsym(a);
61226122 if (cond == 1)
61236123 nocode_wanted |= 0x20000000;
6124− block(bsym, csym, 0);
6124+ block(bsym, bcl, csym, ccl, 0);
61256125 gsym(d); /* patch else jmp */
61266126 if (cond != 0)
61276127 nocode_wanted = saved_nocode_wanted;
@@ -6140,7 +6140,7 @@ static void block(int *bsym, int *csym, int is_expr) · 12 unmodified lines
61406140 b = 0;
61416141 ++local_scope;
61426142 saved_nocode_wanted = nocode_wanted;
6143− block(&a, &b, 0);
6143+ block(&a, current_cleanups, &b, current_cleanups, 0);
61446144 nocode_wanted = saved_nocode_wanted;
61456145 --local_scope;
61466146 gjmp_addr(d);
@@ -6182,7 +6182,7 @@ static void block(int *bsym, int *csym, int is_expr) · 35 unmodified lines
61826182 if (tok != '}') {
61836183 if (is_expr)
61846184 vpop();
6185− block(bsym, csym, is_expr);
6185+ block(bsym, bcl, csym, ccl, is_expr);
61866186 }
61876187 }
61886188
@@ -6258,6 +6258,7 @@ static void block(int *bsym, int *csym, int is_expr) · 69 unmodified lines
62586258 /* compute jump */
62596259 if (!bsym)
62606260 tcc_error("cannot break");
6261+ try_call_scope_cleanup(bcl);
62616262 *bsym = gjmp(*bsym);
62626263 next();
62636264 skip(';');
@@ -6266,6 +6267,7 @@ static void block(int *bsym, int *csym, int is_expr) · 2 unmodified lines
62666267 /* compute jump */
62676268 if (!csym)
62686269 tcc_error("cannot continue");
6270+ try_call_scope_cleanup(ccl);
62696271 vla_sp_restore_root();
62706272 *csym = gjmp(*csym);
62716273 next();
@@ -6309,7 +6311,7 @@ static void block(int *bsym, int *csym, int is_expr) · 37 unmodified lines
63096311 }
63106312 skip(')');
63116313 saved_nocode_wanted = nocode_wanted;
6312− block(&a, &b, 0);
6314+ block(&a, current_cleanups, &b, current_cleanups, 0);
63136315 nocode_wanted = saved_nocode_wanted;
63146316 gjmp_addr(c);
63156317 gsym(a);
@@ -6327,7 +6329,7 @@ static void block(int *bsym, int *csym, int is_expr) · 11 unmodified lines
63276329 d = ind;
63286330 vla_sp_restore();
63296331 saved_nocode_wanted = nocode_wanted;
6330− block(&a, &b, 0);
6332+ block(&a, current_cleanups, &b, current_cleanups, 0);
63316333 skip(TOK_WHILE);
63326334 skip('(');
63336335 gsym(b);
@@ -6355,7 +6357,7 @@ static void block(int *bsym, int *csym, int is_expr) · 21 unmodified lines
63556357 sw.p = NULL; sw.n = 0; sw.def_sym = 0;
63566358 saved = cur_switch;
63576359 cur_switch = &sw;
6358− block(&a, csym, 0);
6360+ block(&a, current_cleanups, csym, ccl, 0);
63596361 nocode_wanted = saved_nocode_wanted;
63606362 a = gjmp(a); /* add implicit break */
63616363 /* case lookup */
@@ -6477,7 +6479,7 @@ static void block(int *bsym, int *csym, int is_expr) · 115 unmodified lines
64776479 } else {
64786480 if (is_expr)
64796481 vpop();
6480− block(bsym, csym, is_expr);
6482+ block(bsym, bcl, csym, ccl, is_expr);
64816483 }
64826484 } else {
64836485 /* expression case */
@@ -7357,7 +7359,7 @@ static void gen_function(Sym *sym) · 873 unmodified lines
73577359 reset_local_scope();
73587360 rsym = 0;
73597361 clear_temp_local_var_list();
7360− block(NULL, NULL, 0);
7362+ block(NULL, NULL, NULL, NULL, 0);
73617363 if (!(nocode_wanted & 0x20000000)
73627364 && ((func_vt.t & VT_BTYPE) == VT_INT)
73637365 && !strcmp (funcname, "main"))

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