harec

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

commit 7a40d6076e9c63bf76ab6a9c37315a9582ff4f07
parent a89b9593e653ae6af309adbeea204aecd5938f95
Author: Armin Weigl <tb46305@gmail.com>
Date:   Fri,  5 Mar 2021 19:37:18 +0100

Prevent use of return in @noreturn functions

Diffstat:
Msrc/check.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -1592,6 +1592,8 @@ check_expr_propagate(struct context *ctx, "Cannot use error propagation with non-tagged type"); expect(&aexpr->loc, !ctx->deferring, "Cannot use error propagation in a defer expression"); + expect(&aexpr->loc, !(ctx->fntype->func.flags & FN_NORETURN), + "Cannot use error propagation inside @noreturn function"); struct type_tagged_union result_tagged = {0}; struct type_tagged_union *tagged = &result_tagged, @@ -1712,6 +1714,8 @@ check_expr_return(struct context *ctx, trenter(TR_CHECK, "return"); expect(&aexpr->loc, !ctx->deferring, "Cannot return inside a defer expression"); + expect(&aexpr->loc, !(ctx->fntype->func.flags & FN_NORETURN), + "Cannot return inside @noreturn function"); expr->type = EXPR_RETURN; expr->result = &builtin_type_void;