summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-25 00:55:24 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-25 00:55:24 +0000
commitd0ace024965bb68e3d4a5a082f1b94fa56253198 (patch)
tree6e7d0f43247cc8916fde57366f04bd1447cbe8ac /clang/lib/Sema/SemaInit.cpp
parent53e1ba948d218d8de028fa8c522ee1e903ee533a (diff)
downloadbcm5719-llvm-d0ace024965bb68e3d4a5a082f1b94fa56253198.tar.gz
bcm5719-llvm-d0ace024965bb68e3d4a5a082f1b94fa56253198.zip
When copying a temporary object to initialize an entity for which the
temporary needs to be bound, bind the copy object. Otherwise, we won't end up calling the destructor for the copy. Fixes Boost.Optional. llvm-svn: 102290
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index e1269a7e129..c413e67f042 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3355,8 +3355,14 @@ static Sema::OwningExprResult CopyObject(Sema &S,
Loc, ConstructorArgs))
return S.ExprError();
- return S.BuildCXXConstructExpr(Loc, T, Constructor, Elidable,
- move_arg(ConstructorArgs));
+ // Actually perform the constructor call.
+ CurInit = S.BuildCXXConstructExpr(Loc, T, Constructor, Elidable,
+ move_arg(ConstructorArgs));
+
+ // If we're supposed to bind temporaries, do so.
+ if (!CurInit.isInvalid() && shouldBindAsTemporary(Entity))
+ CurInit = S.MaybeBindToTemporary(CurInit.takeAs<Expr>());
+ return move(CurInit);
}
void InitializationSequence::PrintInitLocationNote(Sema &S,
OpenPOWER on IntegriCloud