aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-03-16 23:39:51 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-03-16 23:39:51 +0000
commit8596bbe00e3cd670652ddaf0c22d14aa84bb6fb8 (patch)
tree80a88643d5c66813b689d9f585416250112f64b4
parente5877b08a688daec2ff19648922a9cb3b61d4425 (diff)
Issue error when a byref array is accessed in a block
literal. Fixes radar 7760213. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98693 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp2
-rw-r--r--test/Sema/block-byref-args.c22
-rw-r--r--test/Sema/block-misc.c2
3 files changed, 3 insertions, 23 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 32ed3e0006..d80b25d332 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() && !VD->hasAttr<BlocksAttr>()) {
+ if (VD->getType()->isArrayType()) {
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
deleted file mode 100644
index 255c97b280..0000000000
--- a/test/Sema/block-byref-args.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
-
-int printf(const char *, ...);
-
-int main(int argc, char **argv) {
- __block void(*bobTheFunction)(void);
- __block void(^bobTheBlock)(void);
-
- bobTheBlock = ^{;};
-
- __block int JJJJ;
- __attribute__((__blocks__(byref))) int III;
-
- 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;
-}
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index 1109be6311..ca71ab12b2 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -214,8 +214,10 @@ void test20() {
// radr://7438948
void test21() {
int a[7]; // expected-note {{declared at}}
+ __block int b[10]; // expected-note {{declared at}}
a[1] = 1;
^{
(void)a[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
+ (void)b[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
}();
}