diff options
| author | gingerBill <bill@gingerbill.org> | 2024-02-22 19:14:16 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-02-22 19:14:16 +0000 |
| commit | c14b9d461a5c58d4b80957682f00205714063435 (patch) | |
| tree | 8971fd3642e00e08b0c1a49fd2823b9a22a23f99 /src/llvm_backend_expr.cpp | |
| parent | 8060e3170ebb973167e6beaf3dd1f5e31226f3b1 (diff) | |
Support `using` of a `bit_field` within a `struct`
Diffstat (limited to 'src/llvm_backend_expr.cpp')
| -rw-r--r-- | src/llvm_backend_expr.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 7e000c9e8..5bf2642e6 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -4679,12 +4679,20 @@ gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) { GB_ASSERT(sel.entity != nullptr); if (sel.is_bit_field) { lbAddr addr = lb_build_addr(p, se->expr); - Type *bf_type = base_type(type_deref(lb_addr_type(addr))); - GB_ASSERT(bf_type->kind == Type_BitField); - lbValue a = lb_addr_get_ptr(p, addr); + Selection sub_sel = sel; sub_sel.index.count -= 1; + + Type *bf_type = type_from_selection(type, sub_sel); + bf_type = base_type(type_deref(bf_type)); + GB_ASSERT(bf_type->kind == Type_BitField); + + lbValue a = lb_addr_get_ptr(p, addr); + if (sub_sel.index.count > 0) { + a = lb_emit_deep_field_gep(p, a, sub_sel); + } + i32 index = sel.index[sel.index.count-1]; Entity *f = bf_type->BitField.fields[index]; |