Skip to content

Commit 03bf6f0

Browse files
authored
Refactor: always return TYstruct from toElemStructLit() (dlang#22603)
1 parent 8b0c753 commit 03bf6f0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

compiler/src/dmd/glue/e2ir.d

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,8 +1449,7 @@ elem* toElem(Expression e, ref IRState irs)
14491449
{
14501450
StructLiteralExp sle = StructLiteralExp.create(ne.loc, sd, ne.arguments, t);
14511451
ez = toElemStructLit(sle, irs, EXP.construct, ev.Vsym, false);
1452-
if (tybasic(ez.Ety) == TYstruct || ne.placement)
1453-
ez = el_una(OPaddr, TYnptr, ez);
1452+
ez = el_una(OPaddr, TYnptr, ez);
14541453
}
14551454
static if (0)
14561455
{
@@ -6714,8 +6713,9 @@ elem* toElemCall(CallExp ce, ref IRState irs, elem* ehidden = null)
67146713
* sym = struct symbol to initialize with the literal. If null, an auto is created
67156714
* fillHoles = Fill in alignment holes with zero. Set to
67166715
* false if allocated by operator new, as the holes are already zeroed.
6716+
* Returns:
6717+
* generated elem tree with type TYstruct
67176718
*/
6718-
67196719
elem* toElemStructLit(StructLiteralExp sle, ref IRState irs, EXP op, Symbol* sym, bool fillHoles)
67206720
{
67216721
//printf("[%s] StructLiteralExp.toElem() %s\n", sle.loc.toChars(), sle.toChars());
@@ -6993,6 +6993,8 @@ elem* toElemStructLit(StructLiteralExp sle, ref IRState irs, EXP op, Symbol* sym
69936993
}
69946994

69956995
elem* ev = el_var(stmp);
6996+
if (tybasic(ev.Ety) == TYnptr)
6997+
ev = el_una(OPind, totym(sle.sd.type), ev);
69966998
ev.ET = Type_toCtype(sle.sd.type);
69976999
e = el_combine(e, ev);
69987000
elem_setLoc(e, sle.loc);

0 commit comments

Comments
 (0)