[cfe-commits] r143518 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaObjCProperty.cpp test/SemaObjC/property-10.m
Fariborz Jahanian
fjahanian at apple.com
Tue Nov 1 16:02:16 PDT 2011
Author: fjahanian
Date: Tue Nov 1 18:02:16 2011
New Revision: 143518
URL: http://llvm.org/viewvc/llvm-project?rev=143518&view=rev
Log:
objc: warn if a readonly property has a setter attribute too.
// rdar://10357768
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/property-10.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=143518&r1=143517&r2=143518&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Nov 1 18:02:16 2011
@@ -110,6 +110,7 @@
def OverloadedVirtual : DiagGroup<"overloaded-virtual">;
def ObjCMissingSuperCalls : DiagGroup<"objc-missing-super-calls">;
def ObjCRetainBlockProperty : DiagGroup<"objc-noncopy-retain-block-property">;
+def ObjCReadonlyPropertyHasSetter : DiagGroup<"objc-readonly-with-setter-property">;
def ObjCContinuationPropertyType :DiagGroup<"objc-continuation-property-type">;
def Packed : DiagGroup<"packed">;
def Padded : DiagGroup<"padded">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=143518&r1=143517&r2=143518&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 1 18:02:16 2011
@@ -502,6 +502,9 @@
def warn_objc_property_retain_of_block : Warning<
"retain'ed block property does not copy the block "
"- use copy attribute instead">, InGroup<ObjCRetainBlockProperty>;
+def warn_objc_readonly_property_has_setter : Warning<
+ "setter cannot be specified for a readonly property">,
+ InGroup<ObjCReadonlyPropertyHasSetter>;
def warn_atomic_property_rule : Warning<
"writable atomic property %0 cannot pair a synthesized %select{getter|setter}1 "
"with a user defined %select{getter|setter}2">,
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=143518&r1=143517&r2=143518&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Nov 1 18:02:16 2011
@@ -1798,4 +1798,9 @@
!(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
PropertyTy->isBlockPointerType())
Diag(Loc, diag::warn_objc_property_retain_of_block);
+
+ if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
+ (Attributes & ObjCDeclSpec::DQ_PR_setter))
+ Diag(Loc, diag::warn_objc_readonly_property_has_setter);
+
}
Modified: cfe/trunk/test/SemaObjC/property-10.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-10.m?rev=143518&r1=143517&r2=143518&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-10.m (original)
+++ cfe/trunk/test/SemaObjC/property-10.m Tue Nov 1 18:02:16 2011
@@ -37,3 +37,12 @@
@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}}
@property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}}
@end
+
+// rdar://10357768
+ at interface rdar10357768
+{
+ int n1;
+}
+ at property (readonly, setter=crushN1:) int n1; // expected-warning {{setter cannot be specified for a readonly property}}
+ at end
+
More information about the cfe-commits
mailing list