]> granicus.if.org Git - clang/commitdiff
objective-C: Fixes a bogus warning due to not setting
authorFariborz Jahanian <fjahanian@apple.com>
Sun, 10 Feb 2013 00:16:04 +0000 (00:16 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sun, 10 Feb 2013 00:16:04 +0000 (00:16 +0000)
the "nonatomic" attribute in property redeclaration
in class extension. Also, improved on diagnostics in
this area while at it. // rdar://13156292

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/property-3.m
test/SemaObjC/property-4.m
test/SemaObjC/property-category-3.m

index 615b598e77e3be75983d3b1c6fc63a21a4f7e79c..b2f28d561b2a901df44909ff842634a5483c77cd 100644 (file)
@@ -482,7 +482,7 @@ def warn_readonly_property : Warning<
   "'readwrite' of property inherited from %1">;
 
 def warn_property_attribute : Warning<
-  "property %0 '%1' attribute does not match the property inherited from %2">;
+  "'%1' attribute on property %0 does not match the property inherited from %2">;
 def warn_property_types_are_incompatible : Warning<
   "property type %0 is incompatible with type %1 inherited from %2">;
 def err_undef_interface : Error<"cannot find interface declaration for %0">;
index 298bad8efbb7a8859eb02a34993bc9b32ddb1945..1fe88a26ab0e174d5490eec10a8bfc41333c5897 100644 (file)
@@ -368,6 +368,10 @@ Sema::HandlePropertyInClassExtension(Scope *S,
     PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
   if (Attributes & ObjCDeclSpec::DQ_PR_readwrite)
     PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readwrite);
+  if (Attributes & ObjCDeclSpec::DQ_PR_nonatomic)
+    PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nonatomic);
+  if (Attributes & ObjCDeclSpec::DQ_PR_atomic)
+    PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_atomic);
   // Set setter/getter selector name. Needed later.
   PDecl->setGetterName(GetterSel);
   PDecl->setSetterName(SetterSel);
@@ -1292,15 +1296,21 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
   }
 
   if ((CAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)
-      != (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic))
+      != (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)) {
     Diag(Property->getLocation(), diag::warn_property_attribute)
       << Property->getDeclName() << "atomic" << inheritedName;
-  if (Property->getSetterName() != SuperProperty->getSetterName())
+    Diag(SuperProperty->getLocation(), diag::note_property_declare);
+  }
+  if (Property->getSetterName() != SuperProperty->getSetterName()) {
     Diag(Property->getLocation(), diag::warn_property_attribute)
       << Property->getDeclName() << "setter" << inheritedName;
-  if (Property->getGetterName() != SuperProperty->getGetterName())
+    Diag(SuperProperty->getLocation(), diag::note_property_declare);
+  }
+  if (Property->getGetterName() != SuperProperty->getGetterName()) {
     Diag(Property->getLocation(), diag::warn_property_attribute)
       << Property->getDeclName() << "getter" << inheritedName;
+    Diag(SuperProperty->getLocation(), diag::note_property_declare);
+  }
 
   QualType LHSType =
     Context.getCanonicalType(SuperProperty->getType());
index 439dc28be9f204431e94aa04210a7945bf0ffa34..3f82bcc3b7cd5e94960ecb5eee9f49969f4a3bb7 100644 (file)
@@ -9,6 +9,25 @@
 @end
 
 @interface NOW : I
-@property (readonly) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from 'I'}}
+@property (readonly) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{'copy' attribute on property 'd1' does not match the property inherited from 'I'}}
 @property (readwrite, copy) I* d2;
 @end
+
+// rdar://13156292
+typedef signed char BOOL;
+
+@protocol EKProtocolCalendar
+@property (nonatomic, readonly) BOOL allowReminders;
+@property (atomic, readonly) BOOL allowNonatomicProperty; // expected-note {{property declared here}}
+@end
+
+@protocol EKProtocolMutableCalendar <EKProtocolCalendar>
+@end
+
+@interface EKCalendar
+@end
+
+@interface EKCalendar ()  <EKProtocolMutableCalendar>
+@property (nonatomic, assign) BOOL allowReminders;
+@property (nonatomic, assign) BOOL allowNonatomicProperty; // expected-warning {{'atomic' attribute on property 'allowNonatomicProperty' does not match the property inherited from 'EKProtocolCalendar'}}
+@end
index 2168048800ac3ff5eefe0d476c2603391422330e..49f0958fb2193e18dd1871c858a1c36c50879d7c 100644 (file)
@@ -24,6 +24,6 @@
    int newO;
    int oldO;
 }
-@property (retain) id MayCauseError;  // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
+@property (retain) id MayCauseError;  // expected-warning {{'copy' attribute on property 'MayCauseError' does not match the property inherited from 'ProtocolObject'}}
 @end
 
index 47e93a33d24237b1b125a0c2843b7047fed0034c..9be97ae5c8227ddad0d811d167ab568e94cc3cec 100644 (file)
@@ -16,7 +16,7 @@
 @end
 
 @interface I (Cat2) <P1>
-@property (retain) id ID; // expected-warning {{property 'ID' 'copy' attribute does not match the property inherited from 'P1'}}
+@property (retain) id ID; // expected-warning {{'copy' attribute on property 'ID' does not match the property inherited from 'P1'}}
 @end