diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-12 23:17:04 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-12 23:17:04 +0000 |
commit | ba96ffcb2a444d12ffcc4781bd443279c7250d7e (patch) | |
tree | d011b19d2badd184996b7b11385d7608e7bb3030 | |
parent | fa2b3dd31c2fa32f10156e3cbbc8d0cfa2879d03 (diff) |
objc-arc: better diagnostic when block is declared
inside a struct/union.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146444 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | test/SemaObjC/arc-decls.m | 7 |
3 files changed, 9 insertions, 3 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 4f27d9f7ac..7c7b920119 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -3094,7 +3094,7 @@ def err_arc_mismatched_cast : Error< def err_arc_nolifetime_behavior : Error< "explicit ownership qualifier on cast result has no effect">; def err_arc_objc_object_in_struct : Error< - "ARC forbids Objective-C objects in structs or unions">; + "ARC forbids %select{Objective-C objects|blocks}0 in structs or unions">; def err_arc_objc_property_default_assign_on_object : Error< "ARC forbids synthesizing a property of an Objective-C object " "with unspecified ownership or storage attribute">; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 09ada7e55d..bd2e639eab 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9206,7 +9206,8 @@ void Sema::ActOnFields(Scope* S, "this system field has retaining ownership")); } } else { - Diag(FD->getLocation(), diag::err_arc_objc_object_in_struct); + Diag(FD->getLocation(), diag::err_arc_objc_object_in_struct) + << T->isBlockPointerType(); } ARCErrReported = true; } diff --git a/test/SemaObjC/arc-decls.m b/test/SemaObjC/arc-decls.m index 1084db8626..4b7eb8fb54 100644 --- a/test/SemaObjC/arc-decls.m +++ b/test/SemaObjC/arc-decls.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify %s // rdar://8843524 @@ -21,6 +21,11 @@ union u { }; @end +// rdar://10260525 +struct r10260525 { + id (^block) (); // expected-error {{ARC forbids blocks in structs or unions}} +}; + struct S { id __attribute__((objc_ownership(none))) i; void * vp; |