]> granicus.if.org Git - clang/commitdiff
objc: disallow __block attribute on method params.
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 14 Jan 2012 18:44:35 +0000 (18:44 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 14 Jan 2012 18:44:35 +0000 (18:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148197 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/block-on-method-param.m [new file with mode: 0644]

index c20f8f787efcd95e078be9ec063f369a1217105d..ff92453ca7fb00718a97d3862c0f72a0219b8783 100644 (file)
@@ -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 (file)
index 0000000..bb3ad68
--- /dev/null
@@ -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
+