mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Compiler didn't check foreach over flexible array member, and folding a flexible array member was allowed #2164.
This commit is contained in:
15
test/test_suite/statements/foreach_fails.c3
Normal file
15
test/test_suite/statements/foreach_fails.c3
Normal file
@@ -0,0 +1,15 @@
|
||||
struct Abc
|
||||
{
|
||||
int a;
|
||||
int[*] b;
|
||||
}
|
||||
fn void test()
|
||||
{
|
||||
Abc y = {};
|
||||
foreach (x : y.b) {} // #error: It is not possible to enumerate over a flexible
|
||||
}
|
||||
fn int main()
|
||||
{
|
||||
foreach (x : (Abc){}.b) {} // #error: it's a flexible array member
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user