harec

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

commit ef3b83f35a073780623d4e553abcbafab4206076
parent 80be7056f97af15bc321c0b54a9f6d3443bd0078
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu, 24 Dec 2020 11:27:43 -0500

check: forbid nullable pointer dereference

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

diff --git a/src/check.c b/src/check.c @@ -73,6 +73,8 @@ check_expr_assign(struct context *ctx, if (aexpr->assign.indirect) { expect(object->result->storage == TYPE_STORAGE_POINTER, "Cannot dereference non-pointer type for assignment"); + expect(!(object->result->pointer.flags & PTR_NULLABLE), + "Cannot dereference nullable pointer type"); // TODO: Test assignability rules assert(object->result->pointer.referent->storage == value->result->storage); } else { @@ -350,7 +352,9 @@ check_expr_unarithm(struct context *ctx, break; case UN_DEREF: expect(operand->result->storage == TYPE_STORAGE_POINTER, - "Cannot de-reference non-pointer type"); + "Cannot de-reference non-pointer type"); + expect(!(operand->result->pointer.flags & PTR_NULLABLE), + "Cannot dereference nullable pointer type"); expr->result = operand->result->pointer.referent; break; }