Allow use of byref (__block attributed) arrays inside
the block. Fixes radar 7671883.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97863 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d8648f2..10001c3 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1691,7 +1691,7 @@
       return ExprError();
     }
 
-    if (VD->getType()->isArrayType()) {
+    if (VD->getType()->isArrayType() && !VD->hasAttr<BlocksAttr>()) {
       Diag(Loc, diag::err_ref_array_type);
       Diag(D->getLocation(), diag::note_declared_at);
       return ExprError();
diff --git a/test/Sema/block-byref-args.c b/test/Sema/block-byref-args.c
index 7b7cc3d..255c97b 100644
--- a/test/Sema/block-byref-args.c
+++ b/test/Sema/block-byref-args.c
@@ -13,6 +13,10 @@
 
   int (^XXX)(void) = ^{ return III+JJJJ; };
 
+   // rdar 7671883
+   __block char array[10] = {'a', 'b', 'c', 'd'};
+   char (^ch)() = ^{ array[1] = 'X'; return array[5]; };
+   ch();
+
   return 0;
 }
-