r180211 - Objective-C arc: Improve disgnostics when 'weak'
Fariborz Jahanian
fjahanian at apple.com
Wed Apr 24 12:13:05 PDT 2013
Author: fjahanian
Date: Wed Apr 24 14:13:05 2013
New Revision: 180211
URL: http://llvm.org/viewvc/llvm-project?rev=180211&view=rev
Log:
Objective-C arc: Improve disgnostics when 'weak'
property cannot be synthesized because its backing
ivar does not support weak references.
// rdar://13676793
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=180211&r1=180210&r2=180211&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 24 14:13:05 2013
@@ -3789,8 +3789,10 @@ def err_arc_unsupported_weak_class : Err
def err_arc_weak_unavailable_assign : Error<
"assignment of a weak-unavailable object to a __weak object">;
def err_arc_weak_unavailable_property : Error<
- "synthesis of a weak-unavailable property is disallowed "
- "because it requires synthesis of an instance variable of the __weak object">;
+ "synthesizing __weak instance variable of type %0, which does not "
+ "support weak references">;
+def note_implemented_by_class : Note<
+ "when implemented by class %0">;
def err_arc_convesion_of_weak_unavailable : Error<
"%select{implicit conversion|cast}0 of weak-unavailable object of type %1 to"
" a __weak object of type %2">;
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=180211&r1=180210&r2=180211&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Apr 24 14:13:05 2013
@@ -996,8 +996,10 @@ Decl *Sema::ActOnPropertyImplDecl(Scope
PropertyIvarType->getAs<ObjCObjectPointerType>()) {
const ObjCInterfaceDecl *ObjI = ObjT->getInterfaceDecl();
if (ObjI && ObjI->isArcWeakrefUnavailable()) {
- Diag(PropertyDiagLoc, diag::err_arc_weak_unavailable_property);
- Diag(property->getLocation(), diag::note_property_declare);
+ Diag(property->getLocation(),
+ diag::err_arc_weak_unavailable_property) << PropertyIvarType;
+ Diag(ClassImpDecl->getLocation(), diag::note_implemented_by_class)
+ << ClassImpDecl->getName();
err = true;
}
}
Modified: cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m?rev=180211&r1=180210&r2=180211&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m (original)
+++ cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m Wed Apr 24 14:13:05 2013
@@ -56,9 +56,33 @@ __attribute__((objc_arc_weak_reference_u
@interface I
{
}
- at property (weak) NSFont *font; // expected-note {{property declared here}}
+ at property (weak) NSFont *font; // expected-error {{synthesizing __weak instance variable of type 'NSFont *', which does not support weak references}}
@end
- at implementation I
- at synthesize font = _font; // expected-error {{synthesis of a weak-unavailable property is disallowed because it requires synthesis of an instance variable of the __weak object}}
+ at implementation I // expected-note {{when implemented by class I}}
+ at synthesize font = _font;
+ at end
+
+// rdar://13676793
+ at protocol MyProtocol
+ at property (weak) NSFont *font; // expected-error {{synthesizing __weak instance variable of type 'NSFont *', which does not support weak references}}
+ at end
+
+ at interface I1 <MyProtocol>
+ at end
+
+ at implementation I1 // expected-note {{when implemented by class I1}}
+ at synthesize font = _font;
+ at end
+
+ at interface Super
+ at property (weak) NSFont *font; // expected-error {{synthesizing __weak instance variable of type 'NSFont *', which does not support weak references}}
+ at end
+
+
+ at interface I2 : Super
+ at end
+
+ at implementation I2 // expected-note {{when implemented by class I2}}
+ at synthesize font = _font;
@end
More information about the cfe-commits
mailing list