mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Prevent foo.bar = {} when bar is a flexible array member.
This commit is contained in:
25
test/test_suite/struct/flex_more_errors.c3
Normal file
25
test/test_suite/struct/flex_more_errors.c3
Normal file
@@ -0,0 +1,25 @@
|
||||
module main;
|
||||
|
||||
struct OwnedString
|
||||
{
|
||||
usz len;
|
||||
char[*] data;
|
||||
}
|
||||
|
||||
fn void test1()
|
||||
{
|
||||
OwnedString owned;
|
||||
owned.data = {}; // #error: You can't assign to a flexible array member
|
||||
}
|
||||
|
||||
fn void test2()
|
||||
{
|
||||
$typefrom(OwnedString.data.typeid) x = 1; // #error: 'char[*]' has unknown size, and
|
||||
}
|
||||
|
||||
fn int main()
|
||||
{
|
||||
OwnedString owned;
|
||||
owned.data[0] = 1;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user