mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-19 04:12:22 -07:00
Fix typeid comparison bug in ir.cpp
This commit is contained in:
+16
-6
@@ -1035,12 +1035,22 @@ void add_type_and_value(CheckerInfo *i, Ast *expr, AddressingMode mode, Type *ty
|
||||
return;
|
||||
}
|
||||
|
||||
expr->tav.mode = mode;
|
||||
expr->tav.type = type;
|
||||
if (mode == Addressing_Constant || mode == Addressing_Invalid) {
|
||||
expr->tav.value = value;
|
||||
} else if (mode == Addressing_Value && is_type_typeid(type)) {
|
||||
expr->tav.value = value;
|
||||
Ast *prev_expr = nullptr;
|
||||
for (;;) {
|
||||
if (prev_expr != expr) {
|
||||
expr->tav.mode = mode;
|
||||
expr->tav.type = type;
|
||||
if (mode == Addressing_Constant || mode == Addressing_Invalid) {
|
||||
expr->tav.value = value;
|
||||
} else if (mode == Addressing_Value && is_type_typeid(type)) {
|
||||
expr->tav.value = value;
|
||||
}
|
||||
|
||||
prev_expr = expr;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
expr = unparen_expr(expr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -7046,13 +7046,18 @@ irValue *ir_build_expr(irProcedure *proc, Ast *expr) {
|
||||
}
|
||||
|
||||
irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
|
||||
Ast *original_expr = expr;
|
||||
expr = unparen_expr(expr);
|
||||
// ir_push_debug_location(proc->module, expr, proc->debug_scope);
|
||||
// defer (ir_pop_debug_location(proc->module));
|
||||
|
||||
TypeAndValue tv = type_and_value_of_expr(expr);
|
||||
GB_ASSERT(tv.mode != Addressing_Invalid);
|
||||
GB_ASSERT(tv.mode != Addressing_Type);
|
||||
if (tv.mode == Addressing_Type) {
|
||||
// HACK TODO(bill): This is hack but it should be safe in virtually all cases
|
||||
irValue *v = ir_typeid(proc->module, tv.type);
|
||||
return ir_emit_conv(proc, v, t_typeid);
|
||||
}
|
||||
|
||||
if (tv.value.kind != ExactValue_Invalid) {
|
||||
// NOTE(bill): Edge case
|
||||
|
||||
Reference in New Issue
Block a user