From: Fariborz Jahanian Date: Sat, 14 Jan 2012 18:44:35 +0000 (+0000) Subject: objc: disallow __block attribute on method params. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47b1d96bde79633d4aeded1cde2c5f870a58af24;p=clang objc: disallow __block attribute on method params. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148197 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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()) { + 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 +