mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix inline #raw_union bug in issue #87
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ import (
|
|||||||
"raw.odin";
|
"raw.odin";
|
||||||
)
|
)
|
||||||
// Naming Conventions:
|
// Naming Conventions:
|
||||||
// In general, PascalCase for types and snake_case for values
|
// In general, Ada_Case for types and snake_case for values
|
||||||
//
|
//
|
||||||
// Import Name: snake_case (but prefer single word)
|
// Import Name: snake_case (but prefer single word)
|
||||||
// Types: Ada_Case
|
// Types: Ada_Case
|
||||||
|
|||||||
+5
-6
@@ -2523,16 +2523,13 @@ irValue *ir_emit_deep_field_gep(irProcedure *proc, irValue *e, Selection sel) {
|
|||||||
if (is_type_raw_union(type)) {
|
if (is_type_raw_union(type)) {
|
||||||
type = type->Struct.fields[index]->type;
|
type = type->Struct.fields[index]->type;
|
||||||
e = ir_emit_conv(proc, e, make_type_pointer(a, type));
|
e = ir_emit_conv(proc, e, make_type_pointer(a, type));
|
||||||
|
} else if (is_type_struct(type)) {
|
||||||
|
type = type->Struct.fields[index]->type;
|
||||||
|
e = ir_emit_struct_ep(proc, e, index);
|
||||||
} else if (type->kind == Type_Union) {
|
} else if (type->kind == Type_Union) {
|
||||||
GB_ASSERT(index == -1);
|
GB_ASSERT(index == -1);
|
||||||
type = t_type_info_ptr;
|
type = t_type_info_ptr;
|
||||||
e = ir_emit_struct_ep(proc, e, index);
|
e = ir_emit_struct_ep(proc, e, index);
|
||||||
} else if (type->kind == Type_Struct) {
|
|
||||||
type = type->Struct.fields[index]->type;
|
|
||||||
if (type->Struct.is_raw_union) {
|
|
||||||
} else {
|
|
||||||
e = ir_emit_struct_ep(proc, e, index);
|
|
||||||
}
|
|
||||||
} else if (type->kind == Type_Tuple) {
|
} else if (type->kind == Type_Tuple) {
|
||||||
type = type->Tuple.variables[index]->type;
|
type = type->Tuple.variables[index]->type;
|
||||||
e = ir_emit_struct_ep(proc, e, index);
|
e = ir_emit_struct_ep(proc, e, index);
|
||||||
@@ -5159,6 +5156,7 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
|
|||||||
Selection sel = lookup_field(proc->module->allocator, type, selector, false);
|
Selection sel = lookup_field(proc->module->allocator, type, selector, false);
|
||||||
GB_ASSERT(sel.entity != nullptr);
|
GB_ASSERT(sel.entity != nullptr);
|
||||||
|
|
||||||
|
|
||||||
if (sel.entity->type->kind == Type_BitFieldValue) {
|
if (sel.entity->type->kind == Type_BitFieldValue) {
|
||||||
irAddr addr = ir_build_addr(proc, se->expr);
|
irAddr addr = ir_build_addr(proc, se->expr);
|
||||||
Type *bft = type_deref(ir_addr_type(addr));
|
Type *bft = type_deref(ir_addr_type(addr));
|
||||||
@@ -5180,6 +5178,7 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
|
|||||||
return ir_addr(a);
|
return ir_addr(a);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// NOTE(bill): x.0
|
||||||
Type *type = type_deref(type_of_expr(proc->module->info, se->expr));
|
Type *type = type_deref(type_of_expr(proc->module->info, se->expr));
|
||||||
Type *selector_type = base_type(type_of_expr(proc->module->info, se->selector));
|
Type *selector_type = base_type(type_of_expr(proc->module->info, se->selector));
|
||||||
GB_ASSERT_MSG(is_type_integer(selector_type), "%s", type_to_string(selector_type));
|
GB_ASSERT_MSG(is_type_integer(selector_type), "%s", type_to_string(selector_type));
|
||||||
|
|||||||
Reference in New Issue
Block a user