From 2e13db8bc64bc99922b0aeb45443c681c1643c82 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 2 Feb 2010 07:10:35 +0000 Subject: [PATCH] Check in a test case and a nasty workaround for PR6199. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95076 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprCXX.cpp | 4 +++- test/CodeGenCXX/temporaries.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 4253d18c39..8dd747240a 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -309,7 +309,9 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest, if (getContext().getLangOptions().ElideConstructors && E->isElidable()) { const Expr *Arg = E->getArg(0); - if (const ImplicitCastExpr *ICE = dyn_cast(Arg)) { + // FIXME: This 'while' statement should really be an 'if' statement, it's + // added as a workaround for PR6199. + while (const ImplicitCastExpr *ICE = dyn_cast(Arg)) { assert((ICE->getCastKind() == CastExpr::CK_NoOp || ICE->getCastKind() == CastExpr::CK_ConstructorConversion || ICE->getCastKind() == CastExpr::CK_UserDefinedConversion) && diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp index 611781886b..c33ca4ebff 100644 --- a/test/CodeGenCXX/temporaries.cpp +++ b/test/CodeGenCXX/temporaries.cpp @@ -249,3 +249,21 @@ namespace PR5867 { g2(17); } } + +// PR6199 +namespace PR6199 { + struct A { ~A(); }; + + struct B { operator A(); }; + + // CHECK: define void @_ZN6PR61992f2IiEENS_1AET_ + template A f2(T) { + B b; + // CHECK: call void @_ZN6PR61991BcvNS_1AEEv + // CHECK-NEXT: ret void + return b; + } + + template A f2(int); + +} -- 2.40.0