diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4f27d9f7acdf..7c7b920119e4 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/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/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 09ada7e55dc4..bd2e639eab0a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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/clang/test/SemaObjC/arc-decls.m b/clang/test/SemaObjC/arc-decls.m index 1084db86268f..4b7eb8fb54d0 100644 --- a/clang/test/SemaObjC/arc-decls.m +++ b/clang/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;