mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- Bitstruct accidentally allowed other arrays than char arrays #2836
This commit is contained in:
@@ -126,6 +126,7 @@
|
||||
- Early exit in macro call crashes codegen #2820
|
||||
- Empty enums would return the values as zero sized arrays #2838
|
||||
- Store of zero in lowering did not properly handle optionals in some cases #2837
|
||||
- Bitstruct accidentally allowed other arrays than char arrays #2836
|
||||
|
||||
### Stdlib changes
|
||||
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.
|
||||
|
||||
@@ -1107,11 +1107,10 @@ static bool sema_analyse_bitstruct(SemaContext *context, Decl *decl, bool *erase
|
||||
decl->strukt.little_endian = false;
|
||||
}
|
||||
Type *base_type = type->type_kind == TYPE_ARRAY ? type_flatten(type->array.base) : type;
|
||||
if (!type_is_integer(base_type))
|
||||
if (!type_is_integer(base_type) || (type->type_kind == TYPE_ARRAY && type_size(type->array.base) > 1))
|
||||
{
|
||||
SEMA_ERROR(decl->strukt.container_type, "The type of the bitstruct cannot be %s but must be an integer or an array of integers.",
|
||||
type_quoted_error_string(decl->strukt.container_type->type));
|
||||
return false;
|
||||
RETURN_SEMA_ERROR(decl->strukt.container_type, "The type of the bitstruct cannot be %s but must be an integer or an array of chars.",
|
||||
type_quoted_error_string(decl->strukt.container_type->type));
|
||||
}
|
||||
Decl **members = decl->strukt.members;
|
||||
unsigned member_count = vec_size(members);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
bitstruct Foo : FixedBlockPool // #error: The type of the bitstruct cannot be 'FixedBlockPool' but must be an integer or an array of integers
|
||||
bitstruct Foo : FixedBlockPool // #error: The type of the bitstruct cannot be 'FixedBlockPool' but must be an integer
|
||||
{
|
||||
}
|
||||
10
test/test_suite/bitstruct/bitstruct_other_int_array.c3
Normal file
10
test/test_suite/bitstruct/bitstruct_other_int_array.c3
Normal file
@@ -0,0 +1,10 @@
|
||||
bitstruct Foo2 : int[2] // #error: The type of the bitstruct cannot be 'int[2]' but must be an
|
||||
{
|
||||
bool enable_version;
|
||||
}
|
||||
fn void main()
|
||||
{
|
||||
Foo2 a2 = { };
|
||||
Foo2 b2 = { .enable_version, };
|
||||
if (!(a2 & b2)) return;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
bitstruct Test : float // #error: The type of the bitstruct cannot be 'float' but must be an integer or an array of integers.
|
||||
bitstruct Test : float // #error: The type of the bitstruct cannot be 'float' but must be an integer
|
||||
{
|
||||
int a : 1..3;
|
||||
int b : 5..10;
|
||||
|
||||
Reference in New Issue
Block a user