diff options
| author | gingerBill <bill@gingerbill.org> | 2024-04-24 13:10:58 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-04-24 13:10:58 +0100 |
| commit | ec5a84a5379236a2413b8f3115509629879f5b53 (patch) | |
| tree | da2618d4933ad6794239fc74706ee54ad9fa9097 /src/check_type.cpp | |
| parent | 75fcd50b9aff5366a9f0e74e42535cc9e5dec8d7 (diff) | |
Improve code generation for loading `bit_field` fields
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index a6dbb8dfc..77ac91c38 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -955,14 +955,19 @@ gb_internal void check_bit_field_type(CheckerContext *ctx, Type *bit_field_type, GB_ASSERT(is_type_bit_field(bit_field_type)); Type *backing_type = check_type(ctx, bf->backing_type); - if (backing_type == nullptr || !is_valid_bit_field_backing_type(backing_type)) { - error(node, "Backing type for a bit_field must be an integer or an array of an integer"); - return; - } - bit_field_type->BitField.backing_type = backing_type; + bit_field_type->BitField.backing_type = backing_type ? backing_type : t_u8; bit_field_type->BitField.scope = ctx->scope; + if (backing_type == nullptr) { + error(bf->backing_type, "Backing type for a bit_field must be an integer or an array of an integer"); + return; + } + if (!is_valid_bit_field_backing_type(backing_type)) { + error(bf->backing_type, "Backing type for a bit_field must be an integer or an array of an integer"); + return; + } + auto fields = array_make<Entity *>(permanent_allocator(), 0, bf->fields.count); auto bit_sizes = array_make<u8> (permanent_allocator(), 0, bf->fields.count); auto tags = array_make<String> (permanent_allocator(), 0, bf->fields.count); |