"function %0 declared 'noreturn' should not return">;
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_shufflevector_non_vector : Error<
"first two arguments to __builtin_shufflevector must be vectors">;
return NewVD->setInvalidDecl();
}
+ if (!NewVD->hasLocalStorage() && NewVD->hasAttr<BlocksAttr>()) {
+ Diag(NewVD->getLocation(), diag::err_block_on_nonlocal);
+ return NewVD->setInvalidDecl();
+ }
+
if (PrevDecl) {
Redeclaration = true;
MergeVarDecl(NewVD, PrevDecl);
IdResolver.AddDecl(New);
ProcessDeclAttributes(New, D);
+
+ if (New->hasAttr<BlocksAttr>()) {
+ Diag(New->getLocation(), diag::err_block_on_nonlocal);
+ }
return DeclPtrTy::make(New);
}
return DeclPtrTy::make(FileScopeAsmDecl::Create(Context, CurContext,
Loc, AsmString));
}
-
void test15() {
foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}}
}
+
+__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}}
+ 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}}
+}
+