diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-25 00:55:24 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-25 00:55:24 +0000 |
commit | b86cf0c11712fa89f14197f3f0ed862e7b2add84 (patch) | |
tree | 11221796e90bf8aa03f15bf189a3bc250ac30cc0 /lib/Sema/SemaInit.cpp | |
parent | 8e142ccf1196c9ae31f10f9caa97670e343971e7 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102290 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index e1269a7e12..c413e67f04 100644 --- a/lib/Sema/SemaInit.cpp +++ b/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, |