зеркало из https://github.com/microsoft/clang-1.git
objc-arc: diagnose synthesis of a 'weak unavailable' property.
// rdar://10535245 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146272 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
44d95b5571
Коммит
6dce88d9f7
|
@ -3066,6 +3066,9 @@ def err_arc_unsupported_weak_class : Error<
|
|||
"class is incompatible with __weak references">;
|
||||
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 ivar of the __weak object">;
|
||||
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">;
|
||||
|
|
|
@ -648,13 +648,21 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
|
|||
Qualifiers::ObjCLifetime lifetime =
|
||||
getImpliedARCOwnership(kind, PropertyIvarType);
|
||||
assert(lifetime && "no lifetime for property?");
|
||||
|
||||
if (lifetime == Qualifiers::OCL_Weak &&
|
||||
!getLangOptions().ObjCRuntimeHasWeak) {
|
||||
Diag(PropertyLoc, diag::err_arc_weak_no_runtime);
|
||||
Diag(property->getLocation(), diag::note_property_declare);
|
||||
if (lifetime == Qualifiers::OCL_Weak) {
|
||||
bool err = false;
|
||||
if (const ObjCObjectPointerType *ObjT =
|
||||
PropertyIvarType->getAs<ObjCObjectPointerType>())
|
||||
if (ObjT->getInterfaceDecl()->isArcWeakrefUnavailable()) {
|
||||
Diag(PropertyLoc, diag::err_arc_weak_unavailable_property);
|
||||
Diag(property->getLocation(), diag::note_property_declare);
|
||||
err = true;
|
||||
}
|
||||
if (!err && !getLangOptions().ObjCRuntimeHasWeak) {
|
||||
Diag(PropertyLoc, diag::err_arc_weak_no_runtime);
|
||||
Diag(property->getLocation(), diag::note_property_declare);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Qualifiers qs;
|
||||
qs.addObjCLifetime(lifetime);
|
||||
PropertyIvarType = Context.getQualifiedType(PropertyIvarType, qs);
|
||||
|
|
|
@ -48,3 +48,17 @@ NOWEAK<P, P1> * Test2() {
|
|||
// expected-error {{explicit ownership qualifier on cast result has no effect}}
|
||||
}
|
||||
|
||||
// rdar://10535245
|
||||
__attribute__((objc_arc_weak_reference_unavailable))
|
||||
@interface NSFont
|
||||
@end
|
||||
|
||||
@interface I
|
||||
{
|
||||
}
|
||||
@property (weak) NSFont *font; // expected-note {{property declared here}}
|
||||
@end
|
||||
|
||||
@implementation I
|
||||
@synthesize font = _font; // expected-error {{synthesis of a weak-unavailable property is disallowed because it requires synthesis of an ivar of the __weak object}}
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче