objc-arc: better diagnostic when block is declared

inside a struct/union.

llvm-svn: 146444
This commit is contained in:
Fariborz Jahanian 2011-12-12 23:17:04 +00:00
parent 3c840aad54
commit b989e6e50a
3 changed files with 9 additions and 3 deletions

View File

@ -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">;

View File

@ -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;
}

View File

@ -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;