Skip to content

Commit 908a2e3

Browse files
authored
Merge pull request #4619 from kinke/merge_stable
Merge upstream stable
2 parents d2498cc + 0a09084 commit 908a2e3

File tree

6 files changed

+109
-10
lines changed

6 files changed

+109
-10
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# LDC master
22

33
#### Big news
4-
- Frontend, druntime and Phobos are at version [2.108.0](https://dlang.org/changelog/2.108.0.html). (#4591, #4615)
4+
- Frontend, druntime and Phobos are at version [2.108.0+](https://dlang.org/changelog/2.108.0.html). (#4591, #4615, #4619)
55
- 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)
66

77
#### Platform support

dmd/initsem.d

+13-4
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,13 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
868868
* by the initializer syntax. if a CInitializer has a Designator, it is probably
869869
* a nested anonymous struct
870870
*/
871-
if (cix.initializerList.length)
871+
int found;
872+
foreach (dix; cix.initializerList)
872873
{
873-
DesigInit dix = cix.initializerList[0];
874874
Designators* dlistx = dix.designatorList;
875-
if (dlistx && (*dlistx).length == 1 && (*dlistx)[0].ident)
875+
if (!dlistx)
876+
continue;
877+
if ((*dlistx).length == 1 && (*dlistx)[0].ident)
876878
{
877879
auto id = (*dlistx)[0].ident;
878880
foreach (k, f; sd.fields[]) // linear search for now
@@ -883,11 +885,18 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
883885
si.addInit(id, dix.initializer);
884886
++fieldi;
885887
++index;
886-
continue Loop1;
888+
++found;
889+
break;
887890
}
888891
}
889892
}
893+
else {
894+
error(ci.loc, "only 1 designator currently allowed for C struct field initializer `%s`", toChars(ci));
895+
}
890896
}
897+
898+
if (found == cix.initializerList.length)
899+
continue Loop1;
891900
}
892901

893902
VarDeclaration field;

packaging/reggae_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dea9fd3233cc66f9e1ca8003fff96e2cbbeb5dcf
1+
5260790492c465eedde921080952ea34bb14c524

runtime/druntime/src/core/internal/array/construction.d

+14-3
Original file line numberDiff line numberDiff line change
@@ -526,16 +526,17 @@ Tarr _d_newarraymTX(Tarr : U[], T, U)(size_t[] dims, bool isShared=false) @trust
526526

527527
auto dim = dims[0];
528528

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

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

541542
foreach (i; 0..dim)
@@ -579,6 +580,16 @@ unittest
579580
}
580581
}
581582

583+
// https://issues.dlang.org/show_bug.cgi?id=24436
584+
@system unittest
585+
{
586+
import core.memory : GC;
587+
588+
int[][] a = _d_newarraymTX!(int[][], int)([2, 2]);
589+
590+
assert(!(GC.getAttr(a.ptr) & GC.BlkAttr.NO_SCAN));
591+
}
592+
582593
version (D_ProfileGC)
583594
{
584595
/**

tests/dmd/runnable/test24042.c renamed to tests/dmd/runnable/structinit.c

+79
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,83 @@ void test6()
124124
assert(t.abc[3] == 7);
125125
}
126126

127+
/**************************************/
128+
// https://issues.dlang.org/show_bug.cgi?id=24495
129+
struct Subitem {
130+
int x;
131+
int y;
132+
};
133+
134+
struct Item {
135+
136+
int a;
137+
138+
struct {
139+
int b1;
140+
struct Subitem b2;
141+
int b3;
142+
};
143+
144+
};
145+
146+
void test7() {
147+
148+
struct Item first = {
149+
.a = 1,
150+
.b1 = 2,
151+
.b3 = 3,
152+
};
153+
struct Item second = {
154+
.a = 1,
155+
{
156+
.b1 = 2,
157+
.b2 = { 1, 2 },
158+
.b3 = 3
159+
}
160+
};
161+
162+
assert(second.a == 1);
163+
assert(second.b1 == 2);
164+
assert(second.b2.x == 1);
165+
assert(second.b2.y == 2);
166+
assert(second.b3 == 3);
167+
}
168+
169+
170+
/**************************************/
171+
// https://issues.dlang.org/show_bug.cgi?id=24277
172+
struct S8
173+
{
174+
int s;
175+
struct
176+
{
177+
int vis;
178+
int count;
179+
int id;
180+
struct
181+
{
182+
int symbol;
183+
int state;
184+
} leaf;
185+
};
186+
};
187+
188+
struct S8 s8 = (struct S8) {
189+
.s = 10,
190+
{
191+
.count = 20,
192+
.id = 30,
193+
.leaf = {.symbol = 40, .state = 50},
194+
}
195+
};
196+
197+
void test8()
198+
{
199+
assert(s8.id == 30);
200+
assert(s8.leaf.symbol == 40);
201+
assert(s8.leaf.state == 50);
202+
}
203+
127204
/**************************************/
128205

129206
int main()
@@ -134,5 +211,7 @@ int main()
134211
test4();
135212
test5();
136213
test6();
214+
test7();
215+
test8();
137216
return 0;
138217
}

0 commit comments

Comments
 (0)