@@ -2728,7 +2728,7 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
27282728
27292729 const Expr *Inner = E->getSubExpr ()->skipRValueSubobjectAdjustments ();
27302730 if (std::optional<unsigned > LocalIndex =
2731- allocateLocal (Inner, E->getExtendingDecl ())) {
2731+ allocateLocal (E, Inner-> getType () , E->getExtendingDecl ())) {
27322732 InitLinkScope<Emitter> ILS (this , InitLink::Temp (*LocalIndex));
27332733 if (!this ->emitGetPtrLocal (*LocalIndex, E))
27342734 return false ;
@@ -4029,15 +4029,15 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(DeclTy &&Src, PrimType Ty,
40294029
40304030template <class Emitter >
40314031std::optional<unsigned >
4032- Compiler<Emitter>::allocateLocal(DeclTy &&Src, const ValueDecl *ExtendingDecl) {
4032+ Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
4033+ const ValueDecl *ExtendingDecl) {
40334034 // Make sure we don't accidentally register the same decl twice.
40344035 if ([[maybe_unused]] const auto *VD =
40354036 dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>())) {
40364037 assert (!P.getGlobal (VD));
40374038 assert (!Locals.contains (VD));
40384039 }
40394040
4040- QualType Ty;
40414041 const ValueDecl *Key = nullptr ;
40424042 const Expr *Init = nullptr ;
40434043 bool IsTemporary = false ;
@@ -4050,7 +4050,8 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, const ValueDecl *ExtendingDecl) {
40504050 }
40514051 if (auto *E = Src.dyn_cast <const Expr *>()) {
40524052 IsTemporary = true ;
4053- Ty = E->getType ();
4053+ if (Ty.isNull ())
4054+ Ty = E->getType ();
40544055 }
40554056
40564057 Descriptor *D = P.createDescriptor (
0 commit comments