Skip to content

Commit 7a81c97

Browse files
authored
Merge branch 'dlang:master' into master
2 parents 9d92140 + c933fdd commit 7a81c97

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

compiler/src/dmd/backend/arm/cod2.d

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,8 +1328,6 @@ private void cdmemsetn(ref CGstate cg, ref CodeBuilder cdb,elem* e,ref regm_t pr
13281328
tym_t tyv = tybasic(evalue.Ety);
13291329
const szv = tysize(tyv);
13301330
assert(cast(int)szv > 1);
1331-
if (tyfloating(tyv))
1332-
assert(0); // TODO AArch64
13331331
regm_t vregs = cgstate.allregs & ~cregs;
13341332
scodelem(cgstate,cdb,evalue,vregs,cregs,false);
13351333

@@ -1396,14 +1394,20 @@ private void cdmemsetn(ref CGstate cg, ref CodeBuilder cdb,elem* e,ref regm_t pr
13961394
uint opc;
13971395
uint imm3;
13981396
INSTR.szToSizeOpc(szv,imm3,opc); // shift 0..4
1399-
assert(szv != REGSIZE * 2); // TODO AArch64
1397+
if (szv == REGSIZE * 2)
1398+
{
1399+
imm3 = 3;
1400+
opc = 0;
1401+
}
14001402
cdb.gen1(INSTR.addsub_ext(1,op,S,opt,Rc,option,imm3,Rd,Rl));
14011403

14021404
if (Rp != Rd)
14031405
genmovreg(cdb,Rp,Rd);
14041406

14051407
cdb.gen1(INSTR.ldst_immpost(imm3,0,0,0,Rp,Rv)); // L2: STR Rv,[Rp],#0 // *Rp++ = Rv
14061408
code* L2 = cdb.last();
1409+
if (szv == REGSIZE * 2)
1410+
cdb.gen1(INSTR.ldst_immpost(imm3,0,0,0,Rp,Rvhi)); // L2: STR Rvhi,[Rp],#0 // *Rp++ = Rvhi
14071411
cdb.gen1(INSTR.cmp_shift(1,Rl,0,0,Rp)); // CMP Rp,Rl
14081412
genBranch(cdb,COND.ne,FL.code,cast(block*)L2); // b.ne L2
14091413
cdb.append(c1);

compiler/src/dmd/e2ir.d

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,14 +1395,13 @@ elem* toElem(Expression e, ref IRState irs)
13951395
/* Structs return a ref, which gets automatically dereferenced.
13961396
* But we want a pointer to the instance.
13971397
*/
1398-
if (!ne.placement)
1399-
ez = el_una(OPaddr, TYnptr, ez);
1398+
ez = el_una(OPaddr, TYnptr, ez);
14001399
}
14011400
else
14021401
{
14031402
StructLiteralExp sle = StructLiteralExp.create(ne.loc, sd, ne.arguments, t);
14041403
ez = toElemStructLit(sle, irs, EXP.construct, ev.Vsym, false);
1405-
if (tybasic(ez.Ety) == TYstruct && !ne.placement)
1404+
if (tybasic(ez.Ety) == TYstruct || ne.placement)
14061405
ez = el_una(OPaddr, TYnptr, ez);
14071406
}
14081407
static if (0)
@@ -1415,13 +1414,6 @@ elem* toElem(Expression e, ref IRState irs)
14151414
printf("\n");
14161415
}
14171416

1418-
if (ne.placement)
1419-
{
1420-
ez = el_bin(OPstreq,TYstruct,el_copytree(ev),ez);
1421-
ez.ET = ev.ET;
1422-
ez = el_una(OPaddr, TYnptr, ez);
1423-
}
1424-
14251417
e = el_combine(ex, ey);
14261418
e = el_combine(e, ew);
14271419
e = el_combine(e, ezprefix);

compiler/test/runnable/placenew.d

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,31 @@ void test8()
132132
assert(s.m.a == 3);
133133
}
134134

135+
/*************************************************/
136+
// https://github.com/dlang/dmd/issues/21549
137+
138+
struct Test9
139+
{
140+
size_t a, b = 3;
141+
this(int x)
142+
{
143+
a = x;
144+
}
145+
}
146+
147+
void new9(ref Test9 p)
148+
{
149+
new(p) Test9(1);
150+
}
151+
152+
void test9()
153+
{
154+
Test9 t9 = void;
155+
new9(t9);
156+
assert(t9.a == 1);
157+
// assert(t9.b == 3); // Test9.init not copied yet
158+
}
159+
135160
/*************************************************/
136161

137162
int main()
@@ -144,6 +169,7 @@ int main()
144169
test6();
145170
test7();
146171
test8();
172+
test9();
147173

148174
return 0;
149175
}

0 commit comments

Comments
 (0)