Support distrinct types as the base type of bitstructs. #2218

This commit is contained in:
Christoffer Lerno
2025-06-17 16:49:46 +02:00
parent 99e29bff8d
commit 93640699be
3 changed files with 51 additions and 2 deletions

View File

@@ -1061,8 +1061,8 @@ static bool sema_analyse_bitstruct(SemaContext *context, Decl *decl, bool *erase
if (*erase_decl) return true;
DEBUG_LOG("Beginning analysis of %s.", decl->name ? decl->name : ".anon");
if (!sema_resolve_type_info(context, decl->strukt.container_type, RESOLVE_TYPE_DEFAULT)) return false;
Type *type = decl->strukt.container_type->type->canonical;
Type *base_type = type->type_kind == TYPE_ARRAY ? type->array.base : type;
Type *type = type_flatten(decl->strukt.container_type->type->canonical);
Type *base_type = type->type_kind == TYPE_ARRAY ? type_flatten(type->array.base) : type;
if (!type_is_integer(base_type))
{
SEMA_ERROR(decl->strukt.container_type, "The type of the bitstruct cannot be %s but must be an integer or an array of integers.",