- Empty struct after @if processing was not detected, causing a crash instead of an error.

- Comparing an uint and int[<4>] was incorrectly assumed to be uint compared to int, causing a crash instead of an error.
- When an `int[*][6]` was given too few values, the compiler would assert instead of giving an error.
This commit is contained in:
Christoffer Lerno
2026-01-19 15:01:08 +01:00
parent 0fea6c6056
commit 4512c6446d
11 changed files with 60 additions and 17 deletions

View File

@@ -387,7 +387,10 @@ static bool sema_analyse_union_members(SemaContext *context, Decl *decl)
// Offset is always 0
member->offset = 0;
}
if (!member_count)
{
RETURN_SEMA_ERROR(decl, "No union members exist after processing attributes, this is not allowed. Please make sure it has at least one member.");
}
ASSERT(decl_ok(decl));
// 1. If packed, then the alignment is zero, unless previously given
@@ -644,6 +647,11 @@ static bool sema_analyse_struct_members(SemaContext *context, Decl *decl)
if (offset < sz || offset > MAX_STRUCT_SIZE) RETURN_SEMA_ERROR(member, "Struct member '%s' would cause the struct to become too large (exceeding 2 GB).", member->name);
}
if (!member_count)
{
RETURN_SEMA_ERROR(decl, "No members exist for this struct after processing attributes, creating an invalid empty struct. Please make sure every struct/inner struct has at least one member.");
}
// Set the alignment:
// 1. If packed, use the alignment given, otherwise set to 1.