mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix #complete switch with pointer case doesn't compile #416
This commit is contained in:
+2
-2
@@ -1205,7 +1205,7 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
|
|||||||
GB_PANIC("Unknown type to type switch statement");
|
GB_PANIC("Unknown type to type switch statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr_set_exists(&seen, y.type)) {
|
if (type_ptr_set_exists(&seen, y.type)) {
|
||||||
TokenPos pos = cc->token.pos;
|
TokenPos pos = cc->token.pos;
|
||||||
gbString expr_str = expr_to_string(y.expr);
|
gbString expr_str = expr_to_string(y.expr);
|
||||||
error(y.expr,
|
error(y.expr,
|
||||||
@@ -1257,7 +1257,7 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
|
|||||||
|
|
||||||
for_array(i, variants) {
|
for_array(i, variants) {
|
||||||
Type *t = variants[i];
|
Type *t = variants[i];
|
||||||
if (!ptr_set_exists(&seen, t)) {
|
if (!type_ptr_set_exists(&seen, t)) {
|
||||||
array_add(&unhandled, t);
|
array_add(&unhandled, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -551,8 +551,27 @@ i64 type_offset_of (Type *t, i32 index);
|
|||||||
gbString type_to_string (Type *type);
|
gbString type_to_string (Type *type);
|
||||||
void init_map_internal_types(Type *type);
|
void init_map_internal_types(Type *type);
|
||||||
Type * bit_set_to_int(Type *t);
|
Type * bit_set_to_int(Type *t);
|
||||||
|
bool are_types_identical(Type *x, Type *y);
|
||||||
|
|
||||||
|
|
||||||
|
bool type_ptr_set_exists(PtrSet<Type *> *s, Type *t) {
|
||||||
|
if (ptr_set_exists(s, t)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(bill, 2019-10-05): This is very slow and it's probably a lot
|
||||||
|
// faster to cache types correctly
|
||||||
|
for_array(i, s->entries) {
|
||||||
|
Type *f = s->entries[i].ptr;
|
||||||
|
if (are_types_identical(t, f)) {
|
||||||
|
ptr_set_add(s, t);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Type *base_type(Type *t) {
|
Type *base_type(Type *t) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (t == nullptr) {
|
if (t == nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user