Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream stable #4619

Merged
merged 5 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LDC master

#### Big news
- Frontend, druntime and Phobos are at version [2.108.0](https://dlang.org/changelog/2.108.0.html). (#4591, #4615)
- Frontend, druntime and Phobos are at version [2.108.0+](https://dlang.org/changelog/2.108.0.html). (#4591, #4615, #4619)
- Support for [LLVM 18](https://releases.llvm.org/18.1.0/docs/ReleaseNotes.html). The prebuilt packages use v18.1.3 (except for Android and macOS arm64). (#4599, #4605, #4607, #4604)

#### Platform support
Expand Down
17 changes: 13 additions & 4 deletions dmd/initsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,13 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
* by the initializer syntax. if a CInitializer has a Designator, it is probably
* a nested anonymous struct
*/
if (cix.initializerList.length)
int found;
foreach (dix; cix.initializerList)
{
DesigInit dix = cix.initializerList[0];
Designators* dlistx = dix.designatorList;
if (dlistx && (*dlistx).length == 1 && (*dlistx)[0].ident)
if (!dlistx)
continue;
if ((*dlistx).length == 1 && (*dlistx)[0].ident)
{
auto id = (*dlistx)[0].ident;
foreach (k, f; sd.fields[]) // linear search for now
Expand All @@ -883,11 +885,18 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
si.addInit(id, dix.initializer);
++fieldi;
++index;
continue Loop1;
++found;
break;
}
}
}
else {
error(ci.loc, "only 1 designator currently allowed for C struct field initializer `%s`", toChars(ci));
}
}

if (found == cix.initializerList.length)
continue Loop1;
}

VarDeclaration field;
Expand Down
2 changes: 1 addition & 1 deletion packaging/reggae_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dea9fd3233cc66f9e1ca8003fff96e2cbbeb5dcf
5260790492c465eedde921080952ea34bb14c524
17 changes: 14 additions & 3 deletions runtime/druntime/src/core/internal/array/construction.d
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,17 @@ Tarr _d_newarraymTX(Tarr : U[], T, U)(size_t[] dims, bool isShared=false) @trust

auto dim = dims[0];

debug(PRINTF) printf("__allocateInnerArray(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, dims.length);
debug(PRINTF) printf("__allocateInnerArray(UnqT = %s, dim = %lu, ndims = %lu\n", UnqT.stringof.ptr, dim, dims.length);
if (dims.length == 1)
{
auto r = _d_newarrayT!UnqT(dim, isShared);
return *cast(void[]*)(&r);
}

auto allocSize = (void[]).sizeof * dim;
auto info = __arrayAlloc!UnqT(allocSize);
__setArrayAllocLength!UnqT(info, allocSize, isShared);
// the array-of-arrays holds pointers! Don't use UnqT here!
auto info = __arrayAlloc!(void[])(allocSize);
__setArrayAllocLength!(void[])(info, allocSize, isShared);
auto p = __arrayStart(info)[0 .. dim];

foreach (i; 0..dim)
Expand Down Expand Up @@ -579,6 +580,16 @@ unittest
}
}

// https://issues.dlang.org/show_bug.cgi?id=24436
@system unittest
{
import core.memory : GC;

int[][] a = _d_newarraymTX!(int[][], int)([2, 2]);

assert(!(GC.getAttr(a.ptr) & GC.BlkAttr.NO_SCAN));
}

version (D_ProfileGC)
{
/**
Expand Down
2 changes: 1 addition & 1 deletion runtime/phobos
79 changes: 79 additions & 0 deletions tests/dmd/runnable/test24042.c → tests/dmd/runnable/structinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,83 @@ void test6()
assert(t.abc[3] == 7);
}

/**************************************/
// https://issues.dlang.org/show_bug.cgi?id=24495
struct Subitem {
int x;
int y;
};

struct Item {

int a;

struct {
int b1;
struct Subitem b2;
int b3;
};

};

void test7() {

struct Item first = {
.a = 1,
.b1 = 2,
.b3 = 3,
};
struct Item second = {
.a = 1,
{
.b1 = 2,
.b2 = { 1, 2 },
.b3 = 3
}
};

assert(second.a == 1);
assert(second.b1 == 2);
assert(second.b2.x == 1);
assert(second.b2.y == 2);
assert(second.b3 == 3);
}


/**************************************/
// https://issues.dlang.org/show_bug.cgi?id=24277
struct S8
{
int s;
struct
{
int vis;
int count;
int id;
struct
{
int symbol;
int state;
} leaf;
};
};

struct S8 s8 = (struct S8) {
.s = 10,
{
.count = 20,
.id = 30,
.leaf = {.symbol = 40, .state = 50},
}
};

void test8()
{
assert(s8.id == 30);
assert(s8.leaf.symbol == 40);
assert(s8.leaf.state == 50);
}

/**************************************/

int main()
Expand All @@ -134,5 +211,7 @@ int main()
test4();
test5();
test6();
test7();
test8();
return 0;
}
Loading