aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index a9adb70050..db888a62a4 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -3297,15 +3297,31 @@ InitializationSequence::Perform(Sema &S,
// Check exception specifications
if (S.CheckExceptionSpecCompatibility(CurInitExpr, DestType))
return S.ExprError();
+
+ // FIXME: We should do this for all types.
+ if (DestType->isAnyComplexType()) {
+ CurInit =
+ S.Owned(CXXBindReferenceExpr::Create(S.Context,
+ CurInit.takeAs<Expr>(),
+ /*ExtendsLifetime=*/false,
+ /*RequiresTemporaryCopy=*/false));
+ }
+
break;
-
+
case SK_BindReferenceToTemporary:
// Check exception specifications
if (S.CheckExceptionSpecCompatibility(CurInitExpr, DestType))
return S.ExprError();
- // FIXME: At present, we have no AST to describe when we need to make a
- // temporary to bind a reference to. We should.
+ // FIXME: We should do this for all types.
+ if (DestType->isAnyComplexType()) {
+ CurInit =
+ S.Owned(CXXBindReferenceExpr::Create(S.Context,
+ CurInit.takeAs<Expr>(),
+ /*ExtendsLifetime=*/false,
+ /*RequiresTemporaryCopy=*/true));
+ }
break;
case SK_UserConversion: {