From 2b3ffeb882be8c43a1816ecec2b326b5027b32ac Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 5 Nov 2023 16:11:19 +0100 Subject: [PATCH] Merge fix: Adapt to removed CommaExp::copy() --- dmd/ldcbindings.d | 1 + dmd/ldcbindings.h | 4 ++++ gen/toir.cpp | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dmd/ldcbindings.d b/dmd/ldcbindings.d index e68aee435dd..b115ba90143 100644 --- a/dmd/ldcbindings.d +++ b/dmd/ldcbindings.d @@ -83,3 +83,4 @@ Expression createExpressionForIntOp(const ref Loc loc, TOK op, Expression e1, Ex Expression createExpression(const ref Loc loc, EXP op) { return new Expression(loc, op); } DsymbolExp createDsymbolExp(const ref Loc loc, Dsymbol s) { return new DsymbolExp(loc, s, /*hasOverloads=*/false); } AddrExp createAddrExp(const ref Loc loc, Expression e) { return new AddrExp(loc, e); } +CommaExp createCommaExp(const ref Loc loc, Expression e1, Expression e2, bool generated = true) { return new CommaExp(loc, e1, e2, generated); } diff --git a/dmd/ldcbindings.h b/dmd/ldcbindings.h index a546ced3af8..66a8415227e 100644 --- a/dmd/ldcbindings.h +++ b/dmd/ldcbindings.h @@ -13,6 +13,7 @@ #include "tokens.h" class AddrExp; +class CommaExp; class Dsymbol; class DsymbolExp; class Expression; @@ -36,3 +37,6 @@ Expression *createExpressionForIntOp(const Loc &loc, TOK op, Expression *e1, Exp Expression *createExpression(const Loc &loc, EXP op); DsymbolExp *createDsymbolExp(const Loc &loc, Dsymbol *s); AddrExp *createAddrExp(const Loc &loc, Expression *e); + +// for gen/toir.cpp only: +CommaExp *createCommaExp(const Loc &loc, Expression *e1, Expression *e2, bool generated = true); diff --git a/gen/toir.cpp b/gen/toir.cpp index 54be6b7937e..4264240d6f1 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -15,6 +15,7 @@ #include "dmd/id.h" #include "dmd/identifier.h" #include "dmd/init.h" +#include "dmd/ldcbindings.h" #include "dmd/module.h" #include "dmd/mtype.h" #include "dmd/root/port.h" @@ -638,8 +639,8 @@ class ToElemVisitor : public Visitor { if (auto ce = e->isCommaExp()) { Expression *newCommaRhs = getLValExp(ce->e2); if (newCommaRhs != ce->e2) { - CommaExp *newComma = static_cast(ce->copy()); - newComma->e2 = newCommaRhs; + CommaExp *newComma = + createCommaExp(ce->loc, ce->e1, newCommaRhs, ce->isGenerated); newComma->type = newCommaRhs->type; e = newComma; }