diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | test/Sema/block-misc.c | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index c9bdf13b30..72689b9523 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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">; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index af27229b92..3ae2ba14c9 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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); diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index 397d3e5af6..6786f4d31e 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -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}} } - |