Give MaterializeTemporaryExpr the exact type of the lvalue it binds
to, including cv-qualifications.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133618 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index aec2c6a..5cc5ee1 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -3013,8 +3013,9 @@
friend class ASTStmtWriter;
public:
- MaterializeTemporaryExpr(Expr *Temporary, bool BoundToLvalueReference)
- : Expr(MaterializeTemporaryExprClass, Temporary->getType(),
+ MaterializeTemporaryExpr(QualType T, Expr *Temporary,
+ bool BoundToLvalueReference)
+ : Expr(MaterializeTemporaryExprClass, T,
BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary,
Temporary->isTypeDependent(), Temporary->isValueDependent(),
Temporary->containsUnexpandedParameterPack()),
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 3231455..e93d2d8 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -4080,7 +4080,9 @@
return ExprError();
// Materialize the temporary into memory.
- CurInit = new (S.Context) MaterializeTemporaryExpr(CurInit.get(),
+ CurInit = new (S.Context) MaterializeTemporaryExpr(
+ Entity.getType().getNonReferenceType(),
+ CurInit.get(),
Entity.getType()->isLValueReferenceType());
break;