]> granicus.if.org Git - clang/commitdiff
ObjectiveC ARC. Removes a bogus warning when a weak
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 19 Nov 2013 19:26:30 +0000 (19:26 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 19 Nov 2013 19:26:30 +0000 (19:26 +0000)
property is redeclared as 'weak' in class extension.
// rdar://15465916

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195146 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/arc-decls.m

index 9d18c659c27eced3f364c0dd158e24e8bbf48b9f..d9d9cec1b700da510de72adb53cae7540a9f5990 100644 (file)
@@ -463,10 +463,12 @@ Sema::HandlePropertyInClassExtension(Scope *S,
       QualType PrimaryPropertyQT =
         Context.getCanonicalType(PIDecl->getType()).getUnqualifiedType();
       if (isa<ObjCObjectPointerType>(PrimaryPropertyQT)) {
+        bool PropertyIsWeak = ((PIkind & ObjCPropertyDecl::OBJC_PR_weak) != 0);
         Qualifiers::ObjCLifetime PrimaryPropertyLifeTime =
           PrimaryPropertyQT.getObjCLifetime();
         if (PrimaryPropertyLifeTime == Qualifiers::OCL_None &&
-            (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
+            (Attributes & ObjCDeclSpec::DQ_PR_weak) &&
+            !PropertyIsWeak) {
               Diag(AtLoc, diag::warn_property_implicitly_mismatched);
               Diag(PIDecl->getLocation(), diag::note_property_declare);
             }
index f8e80c781945acb0260ad99bc0b0333068bf9730..903cea2a0e8a4581582e676fe72a3cfb7647d89f 100644 (file)
@@ -113,8 +113,13 @@ struct __attribute__((objc_ownership(none))) S2 {}; // expected-error {{'objc_ow
 
 @interface SomeClassOwnedByController
 @property (readonly) ControllerClass *controller; // expected-note {{property declared here}}
+
+// rdar://15465916
+@property (readonly, weak) ControllerClass *weak_controller;
 @end
 
 @interface SomeClassOwnedByController ()
 @property (readwrite, weak) ControllerClass *controller; // expected-warning {{primary property declaration is implicitly strong while redeclaration in class extension is weak}}
+
+@property (readwrite, weak) ControllerClass *weak_controller;
 @end