]> granicus.if.org Git - clang/commitdiff
InitializationSequence handles binding to temporaries, so that
authorDouglas Gregor <dgregor@apple.com>
Thu, 24 Dec 2009 17:16:46 +0000 (17:16 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 24 Dec 2009 17:16:46 +0000 (17:16 +0000)
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

lib/Sema/SemaExpr.cpp
test/CodeGenCXX/temporaries.cpp

index a6b409b99face8db11281626e7196d0810ab7a8c..a9acf72644c69ad961fbebb7c5f062c40dede18f 100644 (file)
@@ -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);
       
index f83bbeeac80459dff1148327b4bdfb84ec102fa0..3fd7cfec78678b41cef36876bcd20f21a57a3bd6 100644 (file)
@@ -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);
+  }
+}