From: Anders Carlsson Date: Sun, 16 Aug 2009 03:42:12 +0000 (+0000) Subject: Add MaybeBindToTemporary calls for member call expressions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f68027af2b6ce294a2706f23a1d3cb7ca1b8d37;p=clang Add MaybeBindToTemporary calls for member call expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79171 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index cfcbca4730..b92ecac6a3 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -800,6 +800,9 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { case CXXTypeidExprClass: // C++ 5.2.8p1: The result of a typeid expression is an lvalue of ... return LV_Valid; + case CXXBindTemporaryExprClass: + return cast(this)->getSubExpr()-> + isLvalueInternal(Ctx); case ConditionalOperatorClass: { // Complicated handling is only for C++. if (!Ctx.getLangOptions().CPlusPlus) diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index d45e54a4a5..2b507fb303 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -4345,8 +4345,8 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, if (CheckFunctionCall(Method, TheCall.get())) return true; - - return TheCall.release(); + + return MaybeBindToTemporary(TheCall.release()).release(); } /// BuildCallToObjectOfClassType - Build a call to an object of class diff --git a/test/CodeGenCXX/temp-1.cpp b/test/CodeGenCXX/temp-1.cpp index 21b3e54329..1edcae4acf 100644 --- a/test/CodeGenCXX/temp-1.cpp +++ b/test/CodeGenCXX/temp-1.cpp @@ -12,7 +12,7 @@ void f1() { A().f(); } -// Calls +// Function calls struct B { B(); ~B(); @@ -21,8 +21,24 @@ struct B { B g(); // RUN: grep "call void @_ZN1BC1Ev" %t | count 0 && -// RUN: grep "call void @_ZN1BD1Ev" %t | count 1 +// RUN: grep "call void @_ZN1BD1Ev" %t | count 1 && void f2() { (void)g(); } +// Member function calls +struct C { + C(); + ~C(); + + C f(); +}; + +// RUN: grep "call void @_ZN1CC1Ev" %t | count 1 && +// RUN: grep "call void @_ZN1CD1Ev" %t | count 2 +void f3() { + C().f(); +} + + +