From dbf217af72acefe7702c65dad2d5e534b3de9674 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97863 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 2 +- test/Sema/block-byref-args.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d8648f2b69..10001c356d 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/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/test/Sema/block-byref-args.c b/test/Sema/block-byref-args.c index 7b7cc3d2c4..255c97b280 100644 --- a/test/Sema/block-byref-args.c +++ b/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; } - -- 2.50.1