harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 0ffebdda798e1aa4c473581f8d04471d796bdb91
parent 003c953cf630388e4c39296a9d4bae0cc319b38e
Author: Sebastian <sebastian@sebsite.pw>
Date:   Fri, 13 May 2022 22:57:26 -0400

check: disallow casts on terminating exprs

Signed-off-by: Sebastian <sebastian@sebsite.pw>

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

diff --git a/src/check.c b/src/check.c @@ -1250,6 +1250,11 @@ check_expr_cast(struct context *ctx, // different nonterminal check_expression(ctx, aexpr->cast.value, value, secondary == &builtin_type_void ? NULL : secondary); + if (value->terminates) { + error(ctx, aexpr->cast.value->loc, expr, + "Cast must not operate on terminating expression"); + return; + } const struct type *primary = type_dealias(expr->cast.value->result); switch (aexpr->cast.kind) {