[cfe-commits] r55364 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp test/SemaObjC/property-5.m
Daniel Dunbar
daniel at zuster.org
Tue Aug 26 00:16:44 PDT 2008
Author: ddunbar
Date: Tue Aug 26 02:16:44 2008
New Revision: 55364
URL: http://llvm.org/viewvc/llvm-project?rev=55364&view=rev
Log:
Add ObjCPropertyDecl::isReadOnly.
Respect isReadOnly when generating synthesized method decls.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/test/SemaObjC/property-5.m
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=55364&r1=55363&r2=55364&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Aug 26 02:16:44 2008
@@ -1205,6 +1205,10 @@
void setPropertyAttributes(PropertyAttributeKind PRVal) {
PropertyAttributes |= PRVal;
}
+
+ bool isReadOnly() const {
+ return (PropertyAttributes & OBJC_PR_readonly);
+ }
Selector getGetterName() const { return GetterName; }
void setGetterName(Selector Sel) { GetterName = Sel; }
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=55364&r1=55363&r2=55364&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Aug 26 02:16:44 2008
@@ -433,6 +433,10 @@
}
property->setGetterMethodDecl(GetterDecl);
+ // Skip setter if property is read-only.
+ if (property->isReadOnly())
+ return;
+
// Find the default setter and if one not found, add one.
ObjCMethodDecl *SetterDecl = getInstanceMethod(property->getSetterName());
if (!SetterDecl) {
Modified: cfe/trunk/test/SemaObjC/property-5.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-5.m?rev=55364&r1=55363&r2=55364&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-5.m (original)
+++ cfe/trunk/test/SemaObjC/property-5.m Tue Aug 26 02:16:44 2008
@@ -29,3 +29,6 @@
@property(readonly) ConstData *p_base; // expected-warning {{property type 'ConstData *' does not match property type inherited from 'Data'}}
@end
+void foo(Base *b, id x) {
+ [ b setRef: x ]; // expected-warning {{method '-setRef:' not found}}
+}
More information about the cfe-commits
mailing list