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 81936ef..fbc8889 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -776,6 +776,9 @@
QualType CalleeType = cast<CallExpr>(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 837fb04..9d789bb 100644
--- a/test/SemaCXX/blocks.cpp
+++ b/test/SemaCXX/blocks.cpp
@@ -5,3 +5,7 @@
void tovoid_test(int (^f)(int, int)) {
tovoid(f);
}
+
+void reference_lvalue_test(int& (^f)()) {
+ f() = 10;
+}