]> granicus.if.org Git - clang/commitdiff
A block that returns a reference is an lvalue.
authorAnders Carlsson <andersca@mac.com>
Tue, 26 May 2009 02:03:20 +0000 (02:03 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 26 May 2009 02:03:20 +0000 (02:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72409 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/SemaCXX/blocks.cpp

index 81936efb08612774154523d7561cd9a6f606015d..fbc8889567d35966ff168fc51fc116c923178e58 100644 (file)
@@ -776,6 +776,9 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
     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;
index 837fb0423b9b53d1a5c58a900df71d9d1f947cca..9d789bb3252ad6ce0527322881f56186c2937feb 100644 (file)
@@ -5,3 +5,7 @@ void tovoid(void*);
 void tovoid_test(int (^f)(int, int)) {
   tovoid(f);
 }
+
+void reference_lvalue_test(int& (^f)()) {
+  f() = 10;
+}