From: Douglas Gregor Date: Thu, 24 Dec 2009 17:16:46 +0000 (+0000) Subject: InitializationSequence handles binding to temporaries, so that X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65552c424750aaa58533ca385a90b77c033cc635;p=clang InitializationSequence handles binding to temporaries, so that argument-passing doesn't have to. Fixes PR5867, where we were binding a temporary twice in the AST and, therefore, calling its destructor twice. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92131 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a6b409b99f..a9acf72644 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3234,9 +3234,6 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, return true; Arg = ArgE.takeAs(); - - if (!ProtoArgType->isReferenceType()) - Arg = MaybeBindToTemporary(Arg).takeAs(); } else { ParmVarDecl *Param = FDecl->getParamDecl(i); diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp index f83bbeeac8..3fd7cfec78 100644 --- a/test/CodeGenCXX/temporaries.cpp +++ b/test/CodeGenCXX/temporaries.cpp @@ -216,3 +216,22 @@ I f12() { // CHECK: ret void return "Hello"; } + +// PR5867 +namespace PR5867 { + struct S { + S(); + S(const S &); + ~S(); + }; + + void f(S, int); + // CHECK: define void @_ZN6PR58671gEv + void g() { + // CHECK: call void @_ZN6PR58671SC1Ev + // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi + // CHECK-NEXT: call void @_ZN6PR58671SD1Ev + // CHECK-NEXT: ret void + (f)(S(), 0); + } +}