harec

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

commit 7d5d7be1a165d491d7e03091e929d6c66bf0d3d1
parent 71752074d1f3f7b75fb06302bff64705482318fd
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Mon,  8 Feb 2021 15:41:23 -0500

Require freed expr to be slice, string, or pointer

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

diff --git a/src/check.c b/src/check.c @@ -934,6 +934,11 @@ check_expr_free(struct context *ctx, trace(TR_CHECK, "free"); expr->free.expr = xcalloc(sizeof(struct expression), 1); check_expression(ctx, aexpr->free.expr, expr->free.expr, NULL); + enum type_storage storage = type_dealias(expr->free.expr->result)->storage; + expect(&aexpr->free.expr->loc, + storage == TYPE_STORAGE_SLICE || storage == TYPE_STORAGE_STRING + || storage == TYPE_STORAGE_POINTER, + "free must operate on slice, string, or pointer"); expr->result = &builtin_type_void; }