Begin work for bit_set[...; [N]T] (not working)

This commit is contained in:
gingerBill
2024-07-15 14:49:20 +01:00
parent 5cefab8229
commit 1e37eaf54d
9 changed files with 140 additions and 42 deletions
+4 -17
View File
@@ -939,22 +939,6 @@ gb_internal void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *nam
enum_type->Enum.max_value_index = max_value_index;
}
gb_internal bool is_valid_bit_field_backing_type(Type *type) {
if (type == nullptr) {
return false;
}
type = base_type(type);
if (is_type_untyped(type)) {
return false;
}
if (is_type_integer(type)) {
return true;
}
if (type->kind == Type_Array) {
return is_type_integer(type->Array.elem);
}
return false;
}
gb_internal void check_bit_field_type(CheckerContext *ctx, Type *bit_field_type, Type *named_type, Ast *node) {
ast_node(bf, BitFieldType, node);
@@ -1268,11 +1252,14 @@ gb_internal void check_bit_set_type(CheckerContext *c, Type *type, Type *named_t
Type *t = default_type(lhs.type);
if (bs->underlying != nullptr) {
Type *u = check_type(c, bs->underlying);
// if (!is_valid_bit_field_backing_type(u)) {
if (!is_type_integer(u)) {
gbString ts = type_to_string(u);
error(bs->underlying, "Expected an underlying integer for the bit set, got %s", ts);
gb_string_free(ts);
return;
if (!is_valid_bit_field_backing_type(u)) {
return;
}
}
type->BitSet.underlying = u;
}