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.cpp15
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);