r174821 - objective-C: Fixes a bogus warning due to not setting

Fariborz Jahanian fjahanian at apple.com
Sat Feb 9 16:16:05 PST 2013


Author: fjahanian
Date: Sat Feb  9 18:16:04 2013
New Revision: 174821

URL: http://llvm.org/viewvc/llvm-project?rev=174821&view=rev
Log:
objective-C: Fixes a bogus warning due to not setting
the "nonatomic" attribute in property redeclaration
in class extension. Also, improved on diagnostics in
this area while at it. // rdar://13156292

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=174821&r1=174820&r2=174821&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Feb  9 18:16:04 2013
@@ -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">;

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=174821&r1=174820&r2=174821&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Sat Feb  9 18:16:04 2013
@@ -368,6 +368,10 @@ Sema::HandlePropertyInClassExtension(Sco
     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(ObjCPrope
   }
 
   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());

Modified: cfe/trunk/test/SemaObjC/property-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-3.m?rev=174821&r1=174820&r2=174821&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-3.m (original)
+++ cfe/trunk/test/SemaObjC/property-3.m Sat Feb  9 18:16:04 2013
@@ -9,6 +9,25 @@
 @end
 
 @interface NOW : I
- at 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'}}
+ at 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;
+
+ at protocol EKProtocolCalendar
+ at property (nonatomic, readonly) BOOL allowReminders;
+ at property (atomic, readonly) BOOL allowNonatomicProperty; // expected-note {{property declared here}}
+ at end
+
+ at protocol EKProtocolMutableCalendar <EKProtocolCalendar>
+ at end
+
+ at interface EKCalendar
+ at end
+
+ at interface EKCalendar ()  <EKProtocolMutableCalendar>
+ at property (nonatomic, assign) BOOL allowReminders;
+ at property (nonatomic, assign) BOOL allowNonatomicProperty; // expected-warning {{'atomic' attribute on property 'allowNonatomicProperty' does not match the property inherited from 'EKProtocolCalendar'}}
+ at end

Modified: cfe/trunk/test/SemaObjC/property-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-4.m?rev=174821&r1=174820&r2=174821&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-4.m (original)
+++ cfe/trunk/test/SemaObjC/property-4.m Sat Feb  9 18:16:04 2013
@@ -24,6 +24,6 @@
    int newO;
    int oldO;
 }
- at property (retain) id MayCauseError;  // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
+ at property (retain) id MayCauseError;  // expected-warning {{'copy' attribute on property 'MayCauseError' does not match the property inherited from 'ProtocolObject'}}
 @end
 

Modified: cfe/trunk/test/SemaObjC/property-category-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-3.m?rev=174821&r1=174820&r2=174821&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-3.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-3.m Sat Feb  9 18:16:04 2013
@@ -16,7 +16,7 @@
 @end
 
 @interface I (Cat2) <P1>
- at property (retain) id ID; // expected-warning {{property 'ID' 'copy' attribute does not match the property inherited from 'P1'}}
+ at property (retain) id ID; // expected-warning {{'copy' attribute on property 'ID' does not match the property inherited from 'P1'}}
 @end
 
 





More information about the cfe-commits mailing list