mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Merge pull request #15898 from WalterBright/fix24274
fix Issue 24274 - [REG master] ImportC: unrecognized C initializer wi…
This commit is contained in:
commit
603be63f97
3 changed files with 119 additions and 25 deletions
|
@ -55,10 +55,75 @@ struct S3
|
|||
|
||||
void test3()
|
||||
{
|
||||
struct S3 tn = (struct S3) {{0}, 4};
|
||||
struct S3 tn = (struct S3) {{1}, 4};
|
||||
assert(tn.context[0] == 1);
|
||||
assert(tn.context[1] == 0);
|
||||
assert(tn.context[2] == 0);
|
||||
assert(tn.context[3] == 0);
|
||||
assert(tn.id == 4);
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
// https://issues.dlang.org/show_bug.cgi?id=24274
|
||||
|
||||
struct S0
|
||||
{
|
||||
struct
|
||||
{
|
||||
char short_data[24];
|
||||
};
|
||||
int length;
|
||||
};
|
||||
|
||||
void test4()
|
||||
{
|
||||
struct S0 s0 = { {.short_data = {1}}, .length = 2};
|
||||
assert(s0.short_data[0] == 1);
|
||||
assert(s0.length == 2);
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
|
||||
struct S1
|
||||
{
|
||||
struct
|
||||
{
|
||||
int long_data;
|
||||
char short_data[24];
|
||||
};
|
||||
int length;
|
||||
};
|
||||
|
||||
void test5()
|
||||
{
|
||||
struct S1 s1 = { {.short_data = {7}}, .length = 8};
|
||||
assert(s1.long_data == 0);
|
||||
assert(s1.short_data[0] == 7);
|
||||
assert(s1.length == 8);
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
|
||||
struct S6
|
||||
{
|
||||
int abc[4];
|
||||
};
|
||||
|
||||
void test6()
|
||||
{
|
||||
struct S6 s = {{4},5,6,7};
|
||||
assert(s.abc[0] == 4);
|
||||
assert(s.abc[1] == 0);
|
||||
assert(s.abc[2] == 0);
|
||||
assert(s.abc[3] == 0);
|
||||
|
||||
struct S6 t = {4,{5},6,7};
|
||||
assert(t.abc[0] == 4);
|
||||
assert(t.abc[1] == 5);
|
||||
assert(t.abc[2] == 6);
|
||||
assert(t.abc[3] == 7);
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
|
||||
int main()
|
||||
|
@ -66,5 +131,8 @@ int main()
|
|||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue