mirror of
https://github.com/dlang/dmd.git
synced 2025-04-29 06:30:10 +03:00
Fixes https://github.com/dlang/dmd/issues/21210
This commit is contained in:
parent
ce6cef9762
commit
d66ef6a26d
2 changed files with 31 additions and 2 deletions
|
@ -761,9 +761,13 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
|
||||||
// C11 6.2.5-20 "element type shall be complete whenever the array type is specified"
|
// C11 6.2.5-20 "element type shall be complete whenever the array type is specified"
|
||||||
assert(0); // should have been detected by parser
|
assert(0); // should have been detected by parser
|
||||||
}
|
}
|
||||||
|
auto bt = tsa.nextOf().toBasetype();
|
||||||
|
|
||||||
auto tnsa = tsa.nextOf().toBasetype().isTypeSArray();
|
if (auto tnss = bt.isTypeStruct())
|
||||||
|
{
|
||||||
|
return subStruct(tnss, index);
|
||||||
|
}
|
||||||
|
auto tnsa = bt.isTypeSArray();
|
||||||
auto ai = new ArrayInitializer(ci.loc);
|
auto ai = new ArrayInitializer(ci.loc);
|
||||||
ai.isCarray = true;
|
ai.isCarray = true;
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,30 @@ void test8()
|
||||||
assert(s8.leaf.state == 50);
|
assert(s8.leaf.state == 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************/
|
||||||
|
// https://github.com/dlang/dmd/issues/21210
|
||||||
|
|
||||||
|
struct Sa {int x, y;};
|
||||||
|
struct Sb {
|
||||||
|
struct Sa v[1];
|
||||||
|
};
|
||||||
|
struct Sb s9 = {0};
|
||||||
|
|
||||||
|
void test9()
|
||||||
|
{
|
||||||
|
struct Sb v = {1};
|
||||||
|
__check(v.v[0].x == 1);
|
||||||
|
__check(v.v[0].y == 0);
|
||||||
|
struct Sb v2[1] = {1};
|
||||||
|
__check(v2[0].v[0].x == 1);
|
||||||
|
__check(v2[0].v[0].y == 0);
|
||||||
|
struct Sb v3[2] = {1, 2, 3, 4};
|
||||||
|
__check(v3[0].v[0].x == 1);
|
||||||
|
__check(v3[0].v[0].y == 2);
|
||||||
|
__check(v3[1].v[0].x == 3);
|
||||||
|
__check(v3[1].v[0].y == 4);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************/
|
/**************************************/
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -213,5 +237,6 @@ int main()
|
||||||
test6();
|
test6();
|
||||||
test7();
|
test7();
|
||||||
test8();
|
test8();
|
||||||
|
test9();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue