mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Enable default-initialized static arrays of voids.
With a single byte (implicit and 0) as initializer, as each void element occupies 1 byte. This is required when building T.init for a struct T containing a void[N] with N > 0 and building literals of T.
This commit is contained in:
parent
2f9b58e261
commit
c76ac3496d
1 changed files with 5 additions and 8 deletions
|
@ -404,10 +404,10 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit)
|
||||||
}
|
}
|
||||||
else if (t->ty == Tsarray) {
|
else if (t->ty == Tsarray) {
|
||||||
// T[n] = T
|
// T[n] = T
|
||||||
if (t->nextOf()->toBasetype()->equals(t2)) {
|
if (t->nextOf()->toBasetype()->equals(t2) ||
|
||||||
DtoArrayInit(loc, lhs, rhs, op);
|
DtoArrayElementType(t)->equals(stripModifiers(t2)) ||
|
||||||
}
|
(t->nextOf()->toBasetype()->ty == Tvoid && t2->ty == Tuns8)
|
||||||
else if (DtoArrayElementType(t)->equals(stripModifiers(t2))) {
|
) {
|
||||||
DtoArrayInit(loc, lhs, rhs, op);
|
DtoArrayInit(loc, lhs, rhs, op);
|
||||||
}
|
}
|
||||||
else if (op != -1 && op != TOKblit && !canSkipPostblit &&
|
else if (op != -1 && op != TOKblit && !canSkipPostblit &&
|
||||||
|
@ -1342,12 +1342,9 @@ LLConstant* DtoConstExpInit(Loc& loc, Type* targetType, Expression* exp)
|
||||||
|
|
||||||
if (targetBase->ty == Tsarray)
|
if (targetBase->ty == Tsarray)
|
||||||
{
|
{
|
||||||
if (targetBase->nextOf()->toBasetype()->ty == Tvoid) {
|
|
||||||
error(loc, "static arrays of voids have no default initializer");
|
|
||||||
fatal();
|
|
||||||
}
|
|
||||||
Logger::println("Building constant array initializer to single value.");
|
Logger::println("Building constant array initializer to single value.");
|
||||||
|
|
||||||
|
assert(expBase->size() > 0);
|
||||||
d_uns64 elemCount = targetBase->size() / expBase->size();
|
d_uns64 elemCount = targetBase->size() / expBase->size();
|
||||||
assert(targetBase->size() % expBase->size() == 0);
|
assert(targetBase->size() % expBase->size() == 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue