From: Anders Carlsson Date: Tue, 26 May 2009 02:03:20 +0000 (+0000) Subject: A block that returns a reference is an lvalue. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e5783180acb42c9d9b1be2838370ea5930a2a8b;p=clang A block that returns a reference is an lvalue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72409 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 81936efb08..fbc8889567 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -776,6 +776,9 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { QualType CalleeType = cast(this)->getCallee()->getType(); if (const PointerType *FnTypePtr = CalleeType->getAsPointerType()) CalleeType = FnTypePtr->getPointeeType(); + else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType()) + CalleeType = BPT->getPointeeType(); + if (const FunctionType *FnType = CalleeType->getAsFunctionType()) if (FnType->getResultType()->isLValueReferenceType()) return LV_Valid; diff --git a/test/SemaCXX/blocks.cpp b/test/SemaCXX/blocks.cpp index 837fb0423b..9d789bb325 100644 --- a/test/SemaCXX/blocks.cpp +++ b/test/SemaCXX/blocks.cpp @@ -5,3 +5,7 @@ void tovoid(void*); void tovoid_test(int (^f)(int, int)) { tovoid(f); } + +void reference_lvalue_test(int& (^f)()) { + f() = 10; +}