Skip to content

Commit

Permalink
rewrite non-POD copies (#20581)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored Dec 20, 2024
1 parent 16c013a commit 32a6dfe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compiler/src/dmd/backend/cgelem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3706,6 +3706,20 @@ elem * elstruct(elem *e, Goal goal)
default:
Ldefault:
{
if (e.Eoper == OPstreq && tym < TYMAX && e.E1.Eoper == OPvar && e.E2.Eoper == OPvar && e.ET)
{
/* change (e1 streq e2) to ((e1 = e2), e1)
* A bit restrictive to only allow OPvar
*/
elem* en = el_bin(OPcomma, e.ET.Tty, e, el_copytree(e.E1));
en.ET = e.ET;
e.Eoper = OPeq;
e.Ety = tym;
e.E1.Ety = tym;
e.E2.Ety = tym;
e = en;
break;
}
elem **pe2;
if (e.Eoper == OPstreq)
pe2 = &e.E2;
Expand Down

0 comments on commit 32a6dfe

Please sign in to comment.