]> granicus.if.org Git - clang/commitdiff
Add Sema checking for __block on vm declarations. Radar 6441502
authorMike Stump <mrs@apple.com>
Fri, 1 May 2009 23:41:47 +0000 (23:41 +0000)
committerMike Stump <mrs@apple.com>
Fri, 1 May 2009 23:41:47 +0000 (23:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70601 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/Sema/block-misc.c

index c9bdf13b308d26a95a7bc3bd593701dc8d82af0d..72689b9523a274e66e87e812de69658d7dd0c790 100644 (file)
@@ -1625,6 +1625,8 @@ def err_noreturn_block_has_return_expr : Error<
   "block declared 'noreturn' should not return">;
 def err_block_on_nonlocal : Error<
   "__block attribute not allowed, only allowed on local variables">;
+def err_block_on_vm : Error<
+  "__block attribute not allowed on declaration with a variably modified type">;
 
 def err_shufflevector_non_vector : Error<
   "first two arguments to __builtin_shufflevector must be vectors">;
index af27229b92bf60e92b60ec960220f65005530f0f..3ae2ba14c910fa7cbf4e859d6c377d93fd5d0451 100644 (file)
@@ -1916,6 +1916,11 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
     return NewVD->setInvalidDecl();
   }
     
+  if (isVM && NewVD->hasAttr<BlocksAttr>()) {
+    Diag(NewVD->getLocation(), diag::err_block_on_vm);
+    return NewVD->setInvalidDecl();
+  }
+
   if (PrevDecl) {
     Redeclaration = true;
     MergeVarDecl(NewVD, PrevDecl);
index 397d3e5af6b12f0133eeb875d07fab27c50ffae8..6786f4d31e78d74141cbe738b435c75262b8c19e 100644 (file)
@@ -150,7 +150,9 @@ void test15() {
 __block int test16i;  // expected-error {{__block attribute not allowed, only allowed on local variables}}
 
 void test16(__block int i) { // expected-error {{__block attribute not allowed, only allowed on local variables}}
+  int size = 5;
   extern __block double extern_var; // expected-error {{__block attribute not allowed, only allowed on local variables}}
   static __block char * pch; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+  __block int a[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
+  __block int (*ap)[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
 }
-