diff --git a/tccgen.c b/tccgen.c index 53ce185..02e56eb 100644 --- a/tccgen.c +++ b/tccgen.c @@ -5406,7 +5406,7 @@ static void block(int *bsym, int *csym, int is_expr) gsym(a); gsym_addr(b, d); } else if (tok == '{') { - Sym *llabel; + Sym *llabel, *glabel; int block_vla_sp_loc = vla_sp_loc, saved_vlas_in_scope = vlas_in_scope; next(); @@ -5414,6 +5414,10 @@ static void block(int *bsym, int *csym, int is_expr) s = local_stack; llabel = local_label_stack; ++local_scope; + /* Labels defined inside statement expressions aren't + available from the outside, so record that as well. */ + if (is_expr) + glabel = global_label_stack; /* handle local labels declarations */ if (tok == TOK_LABEL) { @@ -5439,6 +5443,8 @@ static void block(int *bsym, int *csym, int is_expr) block(bsym, csym, is_expr); } } + if (is_expr) + label_pop(&global_label_stack, glabel); /* pop locally defined labels */ label_pop(&local_label_stack, llabel); /* pop locally defined symbols */