harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 608cc0ae5d8ac1d85f9f08893feb946754928b38
parent 97c7bb1e245e94b812f2e6feba2e1fa8f05aab40
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Sat, 11 Dec 2021 23:45:29 +0000

gen: fix deferring @noreturn functions

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Minclude/gen.h | 1+
Msrc/gen.c | 4+++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/gen.h b/include/gen.h @@ -72,6 +72,7 @@ struct gen_context { const struct type *functype; struct gen_binding *bindings; struct gen_scope *scope; + bool deferring; }; struct unit; diff --git a/src/gen.c b/src/gen.c @@ -30,9 +30,10 @@ static void gen_global_decl(struct gen_context *ctx, static void gen_defers(struct gen_context *ctx, struct gen_scope *scope) { - if (!scope) { + if (ctx->deferring || !scope) { return; } + ctx->deferring = true; if (scope->defers) { pushc(ctx->current, "gen defers"); } @@ -40,6 +41,7 @@ gen_defers(struct gen_context *ctx, struct gen_scope *scope) defer = defer->next) { gen_expr(ctx, defer->expr); } + ctx->deferring = false; } static struct gen_scope *