aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-02-28 11:20:11 +0000
committergingerBill <bill@gingerbill.org>2018-02-28 11:20:11 +0000
commitd3ea334e7ab2897bbc948acc57aa9ba073304215 (patch)
tree8f6016ab7bd62c0320c893e0cb7fa6337054420f /src/check_expr.cpp
parent223c473cf64845f0c0824375fa98ca51bad66fc1 (diff)
`cstring`
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index ec6f95b14..7ad75ac48 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -1786,7 +1786,19 @@ bool check_is_castable_to(Checker *c, Operand *operand, Type *y) {
return true;
// }
}
+ // cstring -> string
+ if (src == t_cstring && dst == t_string) {
+ return true;
+ }
+ // cstring -> ^u8
+ if (src == t_cstring && is_type_u8_ptr(dst)) {
+ return true;
+ }
+ // ^u8 -> cstring
+ if (is_type_u8_ptr(src) && dst == t_cstring) {
+ return true;
+ }
// proc <-> proc
if (is_type_proc(src) && is_type_proc(dst)) {
return true;
@@ -5005,7 +5017,7 @@ bool check_set_index_data(Operand *o, Type *type, bool indirection, i64 *max_cou
switch (t->kind) {
case Type_Basic:
- if (is_type_string(t)) {
+ if (t->Basic.kind == Basic_string) {
if (o->mode == Addressing_Constant) {
*max_count = o->value.value_string.len;
}
@@ -5904,7 +5916,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
Type *t = base_type(type_deref(o->type));
switch (t->kind) {
case Type_Basic:
- if (is_type_string(t)) {
+ if (t->Basic.kind == Basic_string) {
valid = true;
if (o->mode == Addressing_Constant) {
max_count = o->value.value_string.len;