[cfe-commits] r148197 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/block-on-method-param.m
Fariborz Jahanian
fjahanian at apple.com
Sat Jan 14 10:44:35 PST 2012
Author: fjahanian
Date: Sat Jan 14 12:44:35 2012
New Revision: 148197
URL: http://llvm.org/viewvc/llvm-project?rev=148197&view=rev
Log:
objc: disallow __block attribute on method params.
Added:
cfe/trunk/test/SemaObjC/block-on-method-param.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=148197&r1=148196&r2=148197&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Jan 14 12:44:35 2012
@@ -2702,6 +2702,10 @@
// 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);
Added: cfe/trunk/test/SemaObjC/block-on-method-param.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-on-method-param.m?rev=148197&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/block-on-method-param.m (added)
+++ cfe/trunk/test/SemaObjC/block-on-method-param.m Sat Jan 14 12:44:35 2012
@@ -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
+ at interface I
+- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+ at end
+
+ at implementation I
+- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp {} // expected-error {{__block attribute not allowed, only allowed on local variables}}
+ at end
+
More information about the cfe-commits
mailing list