commit f01835375e63f3279381782d0ac837420423ef62
parent 105d0970e78eee965a56e96e5e77e39cbec821d3
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 23 Dec 2020 15:55:45 -0500
check: constrain unarithm in compliance with spec
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/check.c b/src/check.c
@@ -301,11 +301,14 @@ check_expr_unarithm(struct context *ctx,
"Cannot perform binary NOT (~) on non-integer type");
expect(!type_is_signed(operand->result),
"Cannot perform binary NOT (~) on signed type");
- // Fallthrough
+ expr->result = operand->result;
+ break;
case UN_MINUS:
case UN_PLUS:
expect(type_is_numeric(operand->result),
"Cannot perform operation on non-numeric type");
+ expect(type_is_signed(operand->result),
+ "Cannot perform operation on unsigned type");
expr->result = operand->result;
break;
case UN_ADDRESS: