aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp5
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");
}
}