Clean up range code for switch

This commit is contained in:
gingerBill
2018-02-17 18:34:14 +00:00
parent c341597657
commit 21432ba96e
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -744,9 +744,9 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) {
}
}
if (a1.mode != Addressing_Invalid &&
if (a1.mode != Addressing_Invalid && b1.mode != Addressing_Invalid &&
lhs.mode == Addressing_Constant && rhs.mode == Addressing_Constant &&
!is_type_string(lhs.type) && !is_type_string(rhs.type)) {
is_type_number(lhs.type) && is_type_number(rhs.type)) {
ExactValue start = lhs.value;
ExactValue end = rhs.value;
ExactValue one = exact_value_i64(1);
+7
View File
@@ -666,6 +666,13 @@ bool is_type_rune(Type *t) {
}
return false;
}
bool is_type_number(Type *t) {
t = core_type(t);
if (t->kind == Type_Basic) {
return (t->Basic.flags & BasicFlag_Numeric) != 0;
}
return false;
}
bool is_type_numeric(Type *t) {
t = core_type(t);
if (t->kind == Type_Basic) {