aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-24 17:16:46 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-24 17:16:46 +0000
commit65552c424750aaa58533ca385a90b77c033cc635 (patch)
treeda760ed7a7e7d3d6b2240ee5a3b3ba135af64ed2
parent9f2df88757c8db3d97fa198f0ad4b6f139baa66a (diff)
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
-rw-r--r--lib/Sema/SemaExpr.cpp3
-rw-r--r--test/CodeGenCXX/temporaries.cpp19
2 files changed, 19 insertions, 3 deletions
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<Expr>();
-
- if (!ProtoArgType->isReferenceType())
- Arg = MaybeBindToTemporary(Arg).takeAs<Expr>();
} 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);
+ }
+}