aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-05-12 22:23:43 +0100
committergingerBill <bill@gingerbill.org>2021-05-12 22:23:43 +0100
commitdfb81431496f68bce56b9a92681a841b072300be (patch)
tree83a3741fc3843662ff3a1207cc433d484b15fdee /src/check_expr.cpp
parentd2fcbf0e1d5488ee3d64f94e488122d7800214eb (diff)
Fix #651
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 60f07a068..a64acf744 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2380,9 +2380,15 @@ bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) {
if (core_type(bt)->kind == Type_Basic) {
if (check_representable_as_constant(c, x->value, bt, &x->value)) {
return true;
- } else if (is_type_pointer(type) && check_is_castable_to(c, x, type)) {
- return true;
+ } else if (check_is_castable_to(c, x, type)) {
+ if (is_type_pointer(type)) {
+ return true;
+ }
}
+ } else if (check_is_castable_to(c, x, type)) {
+ x->value = {};
+ x->mode = Addressing_Value;
+ return true;
}
} else if (check_is_castable_to(c, x, type)) {
if (x->mode != Addressing_Constant) {
@@ -2392,6 +2398,9 @@ bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) {
} else if (is_type_union(type)) {
x->mode = Addressing_Value;
}
+ if (x->mode == Addressing_Value) {
+ x->value = {};
+ }
return true;
}
return false;