harec

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

commit 10b2a3268a46af5020e3a1a50bcbd8e7a728eabf
parent 72f020c5ee0b4e0e2de17f06fcf3ffb1c8c17c46
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon, 16 Jan 2023 04:41:26 -0500

eval: disallow dereference expression

This isn't included in the translation compatible subset.

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

Diffstat:
Msrc/eval.c | 2+-
Mtests/03-pointers.ha | 7+++++++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/eval.c b/src/eval.c @@ -953,7 +953,7 @@ eval_unarithm(struct context *ctx, struct expression *in, struct expression *out out->constant.uval = ~lvalue.constant.uval; break; case UN_DEREF: - assert(0); // TODO + return EVAL_INVALID; case UN_LNOT: out->constant.bval = !lvalue.constant.bval; break; diff --git a/tests/03-pointers.ha b/tests/03-pointers.ha @@ -121,6 +121,13 @@ fn reject() void = { assert(a as *int); }; ") as exited != EXIT_SUCCESS); + + // dereference expression not in translation-compatible subset + assert(compile(" + let a: int = 0; + let b: *int = &a; + let c: int = *b; + ") as exited != EXIT_SUCCESS); }; export fn main() void = {