mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00: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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr->tav.mode = mode;
|
Ast *prev_expr = nullptr;
|
||||||
expr->tav.type = type;
|
for (;;) {
|
||||||
if (mode == Addressing_Constant || mode == Addressing_Invalid) {
|
if (prev_expr != expr) {
|
||||||
expr->tav.value = value;
|
expr->tav.mode = mode;
|
||||||
} else if (mode == Addressing_Value && is_type_typeid(type)) {
|
expr->tav.type = type;
|
||||||
expr->tav.value = value;
|
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) {
|
irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
|
||||||
|
Ast *original_expr = expr;
|
||||||
expr = unparen_expr(expr);
|
expr = unparen_expr(expr);
|
||||||
// ir_push_debug_location(proc->module, expr, proc->debug_scope);
|
// ir_push_debug_location(proc->module, expr, proc->debug_scope);
|
||||||
// defer (ir_pop_debug_location(proc->module));
|
// defer (ir_pop_debug_location(proc->module));
|
||||||
|
|
||||||
TypeAndValue tv = type_and_value_of_expr(expr);
|
TypeAndValue tv = type_and_value_of_expr(expr);
|
||||||
GB_ASSERT(tv.mode != Addressing_Invalid);
|
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) {
|
if (tv.value.kind != ExactValue_Invalid) {
|
||||||
// NOTE(bill): Edge case
|
// NOTE(bill): Edge case
|
||||||
|
|||||||
Reference in New Issue
Block a user