Fix a slight oversight in computing whether a copy constructor is elidable.

Fixes PR5695.

llvm-svn: 90702
This commit is contained in:
Eli Friedman 2009-12-06 09:26:33 +00:00
parent 58ecb2ab51
commit eddf1213e2
2 changed files with 15 additions and 2 deletions

View File

@ -3369,8 +3369,10 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
if (ICE->getCastKind() == CastExpr::CK_NoOp)
E = ICE->getSubExpr();
if (isa<CallExpr>(E) || isa<CXXTemporaryObjectExpr>(E))
if (CallExpr *CE = dyn_cast<CallExpr>(E))
Elidable = !CE->getCallReturnType()->isReferenceType();
else if (isa<CXXTemporaryObjectExpr>(E))
Elidable = true;
}

View File

@ -0,0 +1,11 @@
// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
// PR5695
struct A { A(const A&); ~A(); };
A& a();
void b() {
A x = a();
}
// CHECK: call void @_ZN1AC1ERKS_
// CHECK: call void @_ZN1AD1Ev