aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-04-07 09:55:19 +0100
committerGinger Bill <bill@gingerbill.org>2017-04-07 09:55:19 +0100
commit70f9cacdcec3f4294b19ee22937f990d645bccf2 (patch)
treea6c9adb5125f06b6e0d3098981e134dff0eadb09 /src
parentc067a1f0ec3f8e089d2800e18da7f3db4f3c2a33 (diff)
Fix `cast` to `any` of untyped constants
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/check_expr.c b/src/check_expr.c
index cbca5b41b..546ec608e 100644
--- a/src/check_expr.c
+++ b/src/check_expr.c
@@ -2324,10 +2324,10 @@ void check_cast(Checker *c, Operand *x, Type *type) {
}
}
} else if (check_is_castable_to(c, x, type)) {
- if (x->mode != Addressing_Constant) {
+ can_convert = true;
+ if (x->mode != Addressing_Constant || is_type_any(type)) {
x->mode = Addressing_Value;
}
- can_convert = true;
}
if (!can_convert) {
@@ -2348,7 +2348,9 @@ void check_cast(Checker *c, Operand *x, Type *type) {
if (is_const_expr && !is_type_constant_type(type)) {
final_type = default_type(x->type);
}
- update_expr_type(c, x->expr, final_type, true);
+ if (!is_type_any(final_type)) {
+ update_expr_type(c, x->expr, final_type, true);
+ }
}
x->type = type;
@@ -5349,6 +5351,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
switch (ce->token.kind) {
case Token_cast:
check_cast(c, o, t);
+ o->expr = node;
break;
case Token_transmute: {
if (o->mode == Addressing_Constant) {
@@ -5459,6 +5462,8 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
default:
GB_PANIC("Unknown cast expression");
}
+
+ o->expr = node;
case_end;