From af9553a23aba9bd1a5bfb7d57d405f25b2446875 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Sat, 6 Mar 2010 01:58:53 +0000 Subject: [PATCH] Allow use of byref (__block attributed) arrays inside the block. Fixes radar 7671883. llvm-svn: 97863 --- clang/lib/Sema/SemaExpr.cpp | 2 +- clang/test/Sema/block-byref-args.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d8648f2b692a..10001c356d1c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1691,7 +1691,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, return ExprError(); } - if (VD->getType()->isArrayType()) { + if (VD->getType()->isArrayType() && !VD->hasAttr()) { Diag(Loc, diag::err_ref_array_type); Diag(D->getLocation(), diag::note_declared_at); return ExprError(); diff --git a/clang/test/Sema/block-byref-args.c b/clang/test/Sema/block-byref-args.c index 7b7cc3d2c49b..255c97b280c9 100644 --- a/clang/test/Sema/block-byref-args.c +++ b/clang/test/Sema/block-byref-args.c @@ -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; } - -- GitLab