forked from OSchip/llvm-project
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
This commit is contained in:
parent
53e1ba948d
commit
d0ace02496
|
@ -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,
|
||||
|
|
|
@ -3703,7 +3703,7 @@ static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr* ArgExpr) {
|
|||
const RecordType *TyRec;
|
||||
if (const MemberPointerType *RHSMPType =
|
||||
ArgExpr->getType()->getAs<MemberPointerType>())
|
||||
TyRec = cast<RecordType>(RHSMPType->getClass());
|
||||
TyRec = RHSMPType->getClass()->getAs<RecordType>();
|
||||
else
|
||||
TyRec = ArgExpr->getType()->getAs<RecordType>();
|
||||
if (!TyRec) {
|
||||
|
|
|
@ -301,3 +301,21 @@ namespace PR6648 {
|
|||
zed(foo);
|
||||
}
|
||||
}
|
||||
|
||||
namespace UserConvertToValue {
|
||||
struct X {
|
||||
X(int);
|
||||
X(const X&);
|
||||
~X();
|
||||
};
|
||||
|
||||
void f(X);
|
||||
|
||||
// CHECK: void @_ZN18UserConvertToValue1gEv()
|
||||
void g() {
|
||||
// CHECK: call void @_ZN18UserConvertToValue1XC1Ei
|
||||
// CHECK: call void @_ZN18UserConvertToValue1fENS_1XE
|
||||
// CHECK: call void @_ZN18UserConvertToValue1XD1Ev
|
||||
f(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue