diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-11 13:47:33 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-11 13:47:33 +0100 |
| commit | aea28d5189848746725707d595155726b6b94ea0 (patch) | |
| tree | 546ecb5af16c4eacb1363be3435fa284cd404330 /src/check_type.cpp | |
| parent | 2250eb3e78eb38d22c0e8c288f82e6ded20b3cfe (diff) | |
Allow edge-case where backing type of a `bit_field` is (array of) `u8`, to allow any endian type
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 11e332757..6fe87c2c7 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1133,12 +1133,13 @@ gb_internal void check_bit_field_type(CheckerContext *ctx, Type *bit_field_type, return Endian_Native; }; - EndianKind backing_type_endian_kind = determine_endian_kind(core_array_type(backing_type)); + Type *backing_type_elem = core_array_type(backing_type); + EndianKind backing_type_endian_kind = determine_endian_kind(backing_type_elem); EndianKind endian_kind = Endian_Unknown; for (Entity *f : fields) { EndianKind field_kind = determine_endian_kind(f->type); - if (field_kind && backing_type_endian_kind != field_kind) { + if (field_kind && backing_type_endian_kind != field_kind && backing_type_elem != t_u8) { error(f->token, "All 'bit_field' field types must match the same endian kind as the backing type, i.e. all native, all little, or all big"); } |