From aea28d5189848746725707d595155726b6b94ea0 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 11 May 2024 13:47:33 +0100 Subject: Allow edge-case where backing type of a `bit_field` is (array of) `u8`, to allow any endian type --- src/check_type.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/check_type.cpp') 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"); } -- cgit v1.2.3