]> granicus.if.org Git - clang/commitdiff
Allow use of byref (__block attributed) arrays inside
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 6 Mar 2010 01:58:53 +0000 (01:58 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 6 Mar 2010 01:58:53 +0000 (01:58 +0000)
the block. Fixes radar 7671883.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97863 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/block-byref-args.c

index d8648f2b692a580d3af6fe7917c72be50ffff991..10001c356d1cb257462ccc79d5a0fb2f7b5dd89c 100644 (file)
@@ -1691,7 +1691,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
       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();
index 7b7cc3d2c49b48153c70d768b047c2c6c36c5332..255c97b280c92ef806cf72d6af2546fbaf0f2bff 100644 (file)
@@ -13,6 +13,10 @@ int main(int argc, char **argv) {
 
   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;
 }
-