diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-11 22:36:17 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-11 22:36:17 +0100 |
| commit | 6bfaf4a093fc566c38e97c5c7b80b9586ddf41e9 (patch) | |
| tree | 22420a3514130dde5ff48ec326a1dc4a3fd8fca3 /src | |
| parent | f650690f617ffd7fea817295100acda5cd190998 (diff) | |
Fix another oversight for `bit_field` endian with 1-byte types
Diffstat (limited to 'src')
| -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 88aa4ca1e..4df0c5d19 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1139,14 +1139,15 @@ gb_internal void check_bit_field_type(CheckerContext *ctx, Type *bit_field_type, EndianKind endian_kind = Endian_Unknown; for (Entity *f : fields) { EndianKind field_kind = determine_endian_kind(f->type); + i64 field_size = type_size_of(f->type); - if (field_kind && backing_type_endian_kind != field_kind && backing_type_elem_size > 1) { + if (field_kind && backing_type_endian_kind != field_kind && field_size > 1 && backing_type_elem_size > 1) { 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"); } if (endian_kind == Endian_Unknown) { endian_kind = field_kind; - } else if (field_kind && endian_kind != field_kind) { + } else if (field_kind && endian_kind != field_kind && field_size > 1) { error(f->token, "All 'bit_field' field types must be of the same endian variety, i.e. all native, all little, or all big"); } } |