diff options
| author | Michael Matz <matz@suse.de> | 2017-07-10 22:25:11 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2017-07-10 22:25:11 +0200 |
| commit | 9bea88d61611dc12eeb211e342461f9157177464 (patch) | |
| tree | d8a3c666fce163dd132c7bf01e6c13c1396676c4 /tccpp.c | |
| parent | 2240422da9b55b71cfb32220bb0246ec92bfc432 (diff) | |
| download | tinycc-9bea88d61611dc12eeb211e342461f9157177464.tar.gz tinycc-9bea88d61611dc12eeb211e342461f9157177464.tar.bz2 | |
Fix statement exprs returning a local label
Like returned local variables also labels local to a statement expression
can be returned, and so their symbols must not be immediately freed
(though they need to be removed from the symbol table).
Diffstat (limited to 'tccpp.c')
| -rw-r--r-- | tccpp.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1376,7 +1376,7 @@ ST_FUNC Sym *label_push(Sym **ptop, int v, int flags) /* pop labels until element last is reached. Look if any labels are undefined. Define symbols if '&&label' was used. */ -ST_FUNC void label_pop(Sym **ptop, Sym *slast) +ST_FUNC void label_pop(Sym **ptop, Sym *slast, int keep) { Sym *s, *s1; for(s = *ptop; s != slast; s = s1) { @@ -1395,9 +1395,11 @@ ST_FUNC void label_pop(Sym **ptop, Sym *slast) } /* remove label */ table_ident[s->v - TOK_IDENT]->sym_label = s->prev_tok; - sym_free(s); + if (!keep) + sym_free(s); } - *ptop = slast; + if (!keep) + *ptop = slast; } /* eval an expression for #if/#elif */ |
