<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div style="-webkit-text-size-adjust: auto; "><br></div><div style="-webkit-text-size-adjust: auto; ">On Jan 28, 2013, at 11:12 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br></div><blockquote type="cite" style="-webkit-text-size-adjust: auto; "><div><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div>I find the new warning text much more confusing…it makes it sound like a different type <i>would</i> be allowed. (Yes, I know __unsafe_unretained would work. That still doesn't help.)</div></div></blockquote><div style="-webkit-text-size-adjust: auto; "><br></div><span style="-webkit-text-size-adjust: auto;">Reinstated the prior wording in r</span><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);">173713. I'll see if I can cook up something more generally useful. </span><div><span style="-webkit-text-size-adjust: auto;"><br></span></div><div><span style="-webkit-text-size-adjust: auto;"> - Doug<br></span><div style="-webkit-text-size-adjust: auto; "><br><blockquote type="cite"><div><div><br></div><div><blockquote type="cite">struct S {<br>- A* a; // expected-error {{ARC forbids Objective-C objects in structs or unions}}<br>+ A* a; // expected-error {{ARC forbids Objective-C objects of type 'A *__strong' in struct}}<br>};<br></blockquote><br></div><br><div><div>On Jan 28, 2013, at 11:08 , Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Author: dgregor<br>Date: Mon Jan 28 13:08:09 2013<br>New Revision: 173708<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=173708&view=rev">http://llvm.org/viewvc/llvm-project?rev=173708&view=rev</a><br>Log:<br>Forbid the use of objects in unions in Objective-C++ ARC. Fixes<br><<a href="rdar://problem/13098104">rdar://problem/13098104</a>>.<br><br>Modified:<br> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br> cfe/trunk/lib/Sema/SemaDecl.cpp<br> cfe/trunk/test/ARCMT/checking.m<br> cfe/trunk/test/SemaObjC/arc-decls.m<br><br>Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=173708&r1=173707&r2=173708&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=173708&r1=173707&r2=173708&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 28 13:08:09 2013<br>@@ -3696,8 +3696,9 @@ def err_arc_mismatched_cast : Error<<br> " to %3 is disallowed with ARC">;<br> def err_arc_nolifetime_behavior : Error<<br> "explicit ownership qualifier on cast result has no effect">;<br>-def err_arc_objc_object_in_struct : Error<<br>- "ARC forbids %select{Objective-C objects|blocks}0 in structs or unions">;<br>+def err_arc_objc_object_in_tag : Error<<br>+ "ARC forbids %select{Objective-C objects|blocks}0 of type %1 in "<br>+ "%select{struct|interface|union|<<ERROR>>|enum}2">;<br> def err_arc_objc_property_default_assign_on_object : Error<<br> "ARC forbids synthesizing a property of an Objective-C object "<br> "with unspecified ownership or storage attribute">;<br><br>Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=173708&r1=173707&r2=173708&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=173708&r1=173707&r2=173708&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 28 13:08:09 2013<br>@@ -10498,44 +10498,42 @@ void Sema::ActOnFields(Scope* S,<br> << FixItHint::CreateInsertion(FD->getLocation(), "*");<br> QualType T = Context.getObjCObjectPointerType(FD->getType());<br> FD->setType(T);<br>- } else if (!getLangOpts().CPlusPlus) {<br>- if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported) {<br>- // It's an error in ARC if a field has lifetime.<br>- // We don't want to report this in a system header, though,<br>- // so we just make the field unavailable.<br>- // FIXME: that's really not sufficient; we need to make the type<br>- // itself invalid to, say, initialize or copy.<br>- QualType T = FD->getType();<br>- Qualifiers::ObjCLifetime lifetime = T.getObjCLifetime();<br>- if (lifetime && lifetime != Qualifiers::OCL_ExplicitNone) {<br>- SourceLocation loc = FD->getLocation();<br>- if (getSourceManager().isInSystemHeader(loc)) {<br>- if (!FD->hasAttr<UnavailableAttr>()) {<br>- FD->addAttr(new (Context) UnavailableAttr(loc, Context,<br>- "this system field has retaining ownership"));<br>- }<br>- } else {<br>- Diag(FD->getLocation(), diag::err_arc_objc_object_in_struct) <br>- << T->isBlockPointerType();<br>+ } else if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported &&<br>+ (!getLangOpts().CPlusPlus || Record->isUnion())) {<br>+ // It's an error in ARC if a field has lifetime.<br>+ // We don't want to report this in a system header, though,<br>+ // so we just make the field unavailable.<br>+ // FIXME: that's really not sufficient; we need to make the type<br>+ // itself invalid to, say, initialize or copy.<br>+ QualType T = FD->getType();<br>+ Qualifiers::ObjCLifetime lifetime = T.getObjCLifetime();<br>+ if (lifetime && lifetime != Qualifiers::OCL_ExplicitNone) {<br>+ SourceLocation loc = FD->getLocation();<br>+ if (getSourceManager().isInSystemHeader(loc)) {<br>+ if (!FD->hasAttr<UnavailableAttr>()) {<br>+ FD->addAttr(new (Context) UnavailableAttr(loc, Context,<br>+ "this system field has retaining ownership"));<br> }<br>- ARCErrReported = true;<br>+ } else {<br>+ Diag(FD->getLocation(), diag::err_arc_objc_object_in_tag) <br>+ << T->isBlockPointerType() << T << Record->getTagKind();<br> }<br>+ ARCErrReported = true;<br> }<br>- else if (getLangOpts().ObjC1 &&<br>+ } else if (getLangOpts().ObjC1 &&<br> getLangOpts().getGC() != LangOptions::NonGC &&<br> Record && !Record->hasObjectMember()) {<br>- if (FD->getType()->isObjCObjectPointerType() ||<br>- FD->getType().isObjCGCStrong())<br>+ if (FD->getType()->isObjCObjectPointerType() ||<br>+ FD->getType().isObjCGCStrong())<br>+ Record->setHasObjectMember(true);<br>+ else if (Context.getAsArrayType(FD->getType())) {<br>+ QualType BaseType = Context.getBaseElementType(FD->getType());<br>+ if (BaseType->isRecordType() && <br>+ BaseType->getAs<RecordType>()->getDecl()->hasObjectMember())<br> Record->setHasObjectMember(true);<br>- else if (Context.getAsArrayType(FD->getType())) {<br>- QualType BaseType = Context.getBaseElementType(FD->getType());<br>- if (BaseType->isRecordType() && <br>- BaseType->getAs<RecordType>()->getDecl()->hasObjectMember())<br>- Record->setHasObjectMember(true);<br>- else if (BaseType->isObjCObjectPointerType() ||<br>- BaseType.isObjCGCStrong())<br>- Record->setHasObjectMember(true);<br>- }<br>+ else if (BaseType->isObjCObjectPointerType() ||<br>+ BaseType.isObjCGCStrong())<br>+ Record->setHasObjectMember(true);<br> }<br> }<br> if (Record && FD->getType().isVolatileQualified())<br><br>Modified: cfe/trunk/test/ARCMT/checking.m<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=173708&r1=173707&r2=173708&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=173708&r1=173707&r2=173708&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/ARCMT/checking.m (original)<br>+++ cfe/trunk/test/ARCMT/checking.m Mon Jan 28 13:08:09 2013<br>@@ -117,7 +117,7 @@ void test1(A *a, BOOL b, struct UnsafeS <br> }<br><br> struct S {<br>- A* a; // expected-error {{ARC forbids Objective-C objects in structs or unions}}<br>+ A* a; // expected-error {{ARC forbids Objective-C objects of type 'A *__strong' in struct}}<br> };<br><br> @interface B<br><br>Modified: cfe/trunk/test/SemaObjC/arc-decls.m<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-decls.m?rev=173708&r1=173707&r2=173708&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-decls.m?rev=173708&r1=173707&r2=173708&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/SemaObjC/arc-decls.m (original)<br>+++ cfe/trunk/test/SemaObjC/arc-decls.m Mon Jan 28 13:08:09 2013<br>@@ -3,17 +3,17 @@<br> // <a href="rdar://8843524">rdar://8843524</a><br><br> struct A {<br>- id x; // expected-error {{ARC forbids Objective-C objects in structs or unions}}<br>+ id x; // expected-error {{ARC forbids Objective-C objects of type '__strong id' in struct}}<br> };<br><br> union u {<br>- id u; // expected-error {{ARC forbids Objective-C objects in structs or unions}}<br>+ id u; // expected-error {{ARC forbids Objective-C objects of type '__strong id' in union}}<br> };<br><br> @interface I {<br> struct A a; <br> struct B {<br>- id y[10][20]; // expected-error {{ARC forbids Objective-C objects in structs or unions}}<br>+ id y[10][20]; // expected-error {{ARC forbids Objective-C objects}}<br> id z;<br> } b;<br><br>@@ -23,7 +23,7 @@ union u {<br><br> // <a href="rdar://10260525">rdar://10260525</a><br> struct r10260525 {<br>- id (^block) (); // expected-error {{ARC forbids blocks in structs or unions}}<br>+ id (^block) (); // expected-error {{ARC forbids blocks of type 'id (^__strong)()' in struct}}<br> };<br><br> struct S { <br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br></blockquote></div><br></div></blockquote></div></div></body></html>