diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-01-14 18:44:35 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-01-14 18:44:35 +0000 |
commit | 47b1d96bde79633d4aeded1cde2c5f870a58af24 (patch) | |
tree | e585d2c62d16b239b9c8878f022f20985d92bc98 | |
parent | 448ce0f1b419bb434761422bc5f050bf4b57b703 (diff) |
objc: disallow __block attribute on method params.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148197 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 4 | ||||
-rw-r--r-- | test/SemaObjC/block-on-method-param.m | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index c20f8f787e..ff92453ca7 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2702,6 +2702,10 @@ Decl *Sema::ActOnMethodDeclaration( // Apply the attributes to the parameter. ProcessDeclAttributeList(TUScope, Param, ArgInfo[i].ArgAttrs); + if (Param->hasAttr<BlocksAttr>()) { + Diag(Param->getLocation(), diag::err_block_on_nonlocal); + Param->setInvalidDecl(); + } S->AddDecl(Param); IdResolver.AddDecl(Param); diff --git a/test/SemaObjC/block-on-method-param.m b/test/SemaObjC/block-on-method-param.m new file mode 100644 index 0000000000..bb3ad689f3 --- /dev/null +++ b/test/SemaObjC/block-on-method-param.m @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks %s + +// rdar://10681443 +@interface I +- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp; // expected-error {{__block attribute not allowed, only allowed on local variables}} +@end + +@implementation I +- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp {} // expected-error {{__block attribute not allowed, only allowed on local variables}} +@end + |