From 37790c13a058aa3f445fe83d399b21f3169d03c1 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 10 Jan 2018 21:17:09 +0000 Subject: Fix issue #170 --- src/check_expr.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 500d8cdad..636ae6e95 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1782,6 +1782,12 @@ bool check_is_castable_to(Checker *c, Operand *operand, Type *y) { } void check_cast(Checker *c, Operand *x, Type *type) { + if (!is_operand_value(*x)) { + error(x->expr, "'cast' can only be applied to values"); + x->mode = Addressing_Invalid; + return; + } + bool is_const_expr = x->mode == Addressing_Constant; bool can_convert = false; @@ -1828,6 +1834,12 @@ void check_cast(Checker *c, Operand *x, Type *type) { } bool check_transmute(Checker *c, AstNode *node, Operand *o, Type *t) { + if (!is_operand_value(*o)) { + error(o->expr, "'transmute' can only be applied to values"); + o->mode = Addressing_Invalid; + return false; + } + if (o->mode == Addressing_Constant) { gbString expr_str = expr_to_string(o->expr); error(o->expr, "Cannot transmute a constant expression: '%s'", expr_str); -- cgit v1.2.3