From: Anders Carlsson Date: Sun, 16 Aug 2009 03:06:32 +0000 (+0000) Subject: Make sure to call MaybeBindToTemporary when creating CallExprs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec74c5929c78bd1670619022f6cfd471becf65aa;p=clang Make sure to call MaybeBindToTemporary when creating CallExprs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79168 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 5f1467c733..ef172e5937 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2942,7 +2942,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, return ExprError(); } - return Owned(TheCall.take()); + return MaybeBindToTemporary(TheCall.take()); } Action::OwningExprResult diff --git a/test/CodeGenCXX/temp-1.cpp b/test/CodeGenCXX/temp-1.cpp index 11b83d333b..21b3e54329 100644 --- a/test/CodeGenCXX/temp-1.cpp +++ b/test/CodeGenCXX/temp-1.cpp @@ -5,9 +5,24 @@ struct A { void f(); }; -void f() { - // RUN: grep "call void @_ZN1AC1Ev" %t | count 2 && - // RUN: grep "call void @_ZN1AD1Ev" %t | count 2 - A(); +// RUN: grep "call void @_ZN1AC1Ev" %t | count 2 && +// RUN: grep "call void @_ZN1AD1Ev" %t | count 2 && +void f1() { + (void)A(); A().f(); } + +// Calls +struct B { + B(); + ~B(); +}; + +B g(); + +// RUN: grep "call void @_ZN1BC1Ev" %t | count 0 && +// RUN: grep "call void @_ZN1BD1Ev" %t | count 1 +void f2() { + (void)g(); +} +