[cfe-commits] r86887 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp test/SemaObjC/atomoic-property-synnthesis-rules.m test/SemaObjC/property-category-1.m
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 11 14:40:11 PST 2009
Author: fjahanian
Date: Wed Nov 11 16:40:11 2009
New Revision: 86887
URL: http://llvm.org/viewvc/llvm-project?rev=86887&view=rev
Log:
writable atomic property's setter/getter must be in 'lock' step of
either both synthesized or bith user defined.
Implements radar 6557233.
Added:
cfe/trunk/test/SemaObjC/atomoic-property-synnthesis-rules.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/property-category-1.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=86887&r1=86886&r2=86887&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 11 16:40:11 2009
@@ -269,6 +269,9 @@
def warn_objc_property_copy_missing_on_block : Warning<
"'copy' attribute must be specified for the block property "
"when -fobjc-gc-only is specified">;
+def warn_atomic_property_rule : Warning<
+ "writable atomic property %0 cannot pair a synthesized setter/getter "
+ "with a user defined setter/getter">;
def err_use_continuation_class : Error<
"property declaration in continuation class of %0 is to change a 'readonly' "
"property to 'readwrite'">;
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=86887&r1=86886&r2=86887&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Nov 11 16:40:11 2009
@@ -1447,6 +1447,12 @@
void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
ObjCContainerDecl* IDecl,
bool IncompleteImpl = false);
+
+ /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
+ /// warning) when atomic property has one but not the other user-declared
+ /// setter or getter.
+ void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
+ ObjCContainerDecl* IDecl);
/// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
/// true, or false, accordingly.
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=86887&r1=86886&r2=86887&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Nov 11 16:40:11 2009
@@ -1113,6 +1113,41 @@
assert(false && "invalid ObjCContainerDecl type.");
}
+void
+Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl,
+ ObjCContainerDecl* IDecl) {
+ // Rules apply in non-GC mode only
+ if (getLangOptions().getGCMode() != LangOptions::NonGC)
+ return;
+ for (ObjCContainerDecl::prop_iterator I = IDecl->prop_begin(),
+ E = IDecl->prop_end();
+ I != E; ++I) {
+ ObjCPropertyDecl *Property = (*I);
+ unsigned Attributes = Property->getPropertyAttributes();
+ // We only care about readwrite atomic property.
+ if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
+ !(Attributes & ObjCPropertyDecl::OBJC_PR_readwrite))
+ continue;
+ if (const ObjCPropertyImplDecl *PIDecl
+ = IMPDecl->FindPropertyImplDecl(Property->getIdentifier())) {
+ if (PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
+ continue;
+ ObjCMethodDecl *GetterMethod =
+ IMPDecl->getInstanceMethod(Property->getGetterName());
+ ObjCMethodDecl *SetterMethod =
+ IMPDecl->getInstanceMethod(Property->getSetterName());
+ if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {
+ SourceLocation MethodLoc =
+ (GetterMethod ? GetterMethod->getLocation()
+ : SetterMethod->getLocation());
+ Diag(MethodLoc, diag::warn_atomic_property_rule)
+ << Property->getIdentifier();
+ Diag(Property->getLocation(), diag::note_property_declare);
+ }
+ }
+ }
+}
+
/// ActOnForwardClassDeclaration -
Action::DeclPtrTy
Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
@@ -1608,8 +1643,10 @@
}
if (ObjCImplementationDecl *IC=dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
IC->setAtEndLoc(AtEndLoc);
- if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
+ if (ObjCInterfaceDecl* IDecl = IC->getClassInterface()) {
ImplMethodsVsClassMethods(IC, IDecl);
+ AtomicPropertySetterGetterRules(IC, IDecl);
+ }
} else if (ObjCCategoryImplDecl* CatImplClass =
dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
CatImplClass->setAtEndLoc(AtEndLoc);
Added: cfe/trunk/test/SemaObjC/atomoic-property-synnthesis-rules.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/atomoic-property-synnthesis-rules.m?rev=86887&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/atomoic-property-synnthesis-rules.m (added)
+++ cfe/trunk/test/SemaObjC/atomoic-property-synnthesis-rules.m Wed Nov 11 16:40:11 2009
@@ -0,0 +1,369 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+/*
+ Conditions for warning:
+ 1. the property is atomic
+ 2. the current @implementation contains an @synthesize for the property
+ 3. the current @implementation contains a hand-written setter XOR getter
+ 4. the property is read-write
+
+ Cases marked WARN should warn one the following:
+ warning: Atomic property 'x' has a synthesized setter and a
+ manually-implemented getter, which may break atomicity.
+ warning: Atomic property 'x' has a synthesized getter and a
+ manually-implemented setter, which may break atomicity.
+
+ Cases not marked WARN only satisfy the indicated subset
+ of the conditions required to warn.
+
+ There should be 8 warnings.
+*/
+
+ at interface Foo
+{
+ /* 12 4 */ int GetSet;
+ /* WARN */ int Get;
+ /* WARN */ int Set;
+ /* 12 4 */ int None;
+ /* 2 4 */ int GetSet_Nonatomic;
+ /* 234 */ int Get_Nonatomic;
+ /* 234 */ int Set_Nonatomic;
+ /* 2 4 */ int None_Nonatomic;
+
+ /* 12 */ int GetSet_ReadOnly;
+ /* 123 */ int Get_ReadOnly;
+ /* 123 */ int Set_ReadOnly;
+ /* 12 */ int None_ReadOnly;
+ /* 2 */ int GetSet_Nonatomic_ReadOnly;
+ /* 23 */ int Get_Nonatomic_ReadOnly;
+ /* 23 */ int Set_Nonatomic_ReadOnly;
+ /* 2 */ int None_Nonatomic_ReadOnly;
+
+ /* 12 4 */ int GetSet_ReadWriteInExt;
+ /* WARN */ int Get_ReadWriteInExt;
+ /* WARN */ int Set_ReadWriteInExt;
+ /* 12 4 */ int None_ReadWriteInExt;
+ /* 2 4 */ int GetSet_Nonatomic_ReadWriteInExt;
+ /* 234 */ int Get_Nonatomic_ReadWriteInExt;
+ /* 234 */ int Set_Nonatomic_ReadWriteInExt;
+ /* 2 4 */ int None_Nonatomic_ReadWriteInExt;
+
+
+ /* 12 4 */ int GetSet_LateSynthesize;
+ /* WARN */ int Get_LateSynthesize;
+ /* WARN */ int Set_LateSynthesize;
+ /* 12 4 */ int None_LateSynthesize;
+ /* 2 4 */ int GetSet_Nonatomic_LateSynthesize;
+ /* 234 */ int Get_Nonatomic_LateSynthesize;
+ /* 234 */ int Set_Nonatomic_LateSynthesize;
+ /* 2 4 */ int None_Nonatomic_LateSynthesize;
+
+ /* 12 */ int GetSet_ReadOnly_LateSynthesize;
+ /* 123 */ int Get_ReadOnly_LateSynthesize;
+ /* 123 */ int Set_ReadOnly_LateSynthesize;
+ /* 12 */ int None_ReadOnly_LateSynthesize;
+ /* 2 */ int GetSet_Nonatomic_ReadOnly_LateSynthesize;
+ /* 23 */ int Get_Nonatomic_ReadOnly_LateSynthesize;
+ /* 23 */ int Set_Nonatomic_ReadOnly_LateSynthesize;
+ /* 2 */ int None_Nonatomic_ReadOnly_LateSynthesize;
+
+ /* 12 4 */ int GetSet_ReadWriteInExt_LateSynthesize;
+ /* WARN */ int Get_ReadWriteInExt_LateSynthesize;
+ /* WARN */ int Set_ReadWriteInExt_LateSynthesize;
+ /* 12 4 */ int None_ReadWriteInExt_LateSynthesize;
+ /* 2 4 */ int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
+ /* 234 */ int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
+ /* 234 */ int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
+ /* 2 4 */ int None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+
+ /* 1 4 */ int GetSet_NoSynthesize;
+ /* 1 34 */ int Get_NoSynthesize;
+ /* 1 34 */ int Set_NoSynthesize;
+ /* 1 4 */ int None_NoSynthesize;
+ /* 4 */ int GetSet_Nonatomic_NoSynthesize;
+ /* 34 */ int Get_Nonatomic_NoSynthesize;
+ /* 34 */ int Set_Nonatomic_NoSynthesize;
+ /* 4 */ int None_Nonatomic_NoSynthesize;
+
+ /* 1 */ int GetSet_ReadOnly_NoSynthesize;
+ /* 1 3 */ int Get_ReadOnly_NoSynthesize;
+ /* 1 3 */ int Set_ReadOnly_NoSynthesize;
+ /* 1 */ int None_ReadOnly_NoSynthesize;
+ /* */ int GetSet_Nonatomic_ReadOnly_NoSynthesize;
+ /* 3 */ int Get_Nonatomic_ReadOnly_NoSynthesize;
+ /* 3 */ int Set_Nonatomic_ReadOnly_NoSynthesize;
+ /* */ int None_Nonatomic_ReadOnly_NoSynthesize;
+
+ /* 1 4 */ int GetSet_ReadWriteInExt_NoSynthesize;
+ /* 1 34 */ int Get_ReadWriteInExt_NoSynthesize;
+ /* 1 34 */ int Set_ReadWriteInExt_NoSynthesize;
+ /* 1 4 */ int None_ReadWriteInExt_NoSynthesize;
+ /* 4 */ int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
+ /* 34 */ int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
+ /* 34 */ int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
+ /* 4 */ int None_Nonatomic_ReadWriteInExt_NoSynthesize;
+}
+
+// read-write - might warn
+ at property int GetSet;
+ at property int Get; // expected-note {{property declared here}}
+ at property int Set; // expected-note {{property declared here}}
+ at property int None;
+ at property(nonatomic) int GetSet_Nonatomic;
+ at property(nonatomic) int Get_Nonatomic;
+ at property(nonatomic) int Set_Nonatomic;
+ at property(nonatomic) int None_Nonatomic;
+
+// read-only - must not warn
+ at property(readonly) int GetSet_ReadOnly;
+ at property(readonly) int Get_ReadOnly;
+ at property(readonly) int Set_ReadOnly;
+ at property(readonly) int None_ReadOnly;
+ at property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly;
+ at property(nonatomic,readonly) int Get_Nonatomic_ReadOnly;
+ at property(nonatomic,readonly) int Set_Nonatomic_ReadOnly;
+ at property(nonatomic,readonly) int None_Nonatomic_ReadOnly;
+
+// read-only in class, read-write in class extension - might warn
+ at property(readonly) int GetSet_ReadWriteInExt;
+ at property(readonly) int Get_ReadWriteInExt; // expected-note {{property declared here}}
+ at property(readonly) int Set_ReadWriteInExt; // expected-note {{property declared here}}
+ at property(readonly) int None_ReadWriteInExt;
+ at property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt;
+ at property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt;
+ at property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt;
+ at property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt;
+
+
+// same as above, but @synthesize follows the hand-written methods - might warn
+ at property int GetSet_LateSynthesize;
+ at property int Get_LateSynthesize; // expected-note {{property declared here}}
+ at property int Set_LateSynthesize; // expected-note {{property declared here}}
+ at property int None_LateSynthesize;
+ at property(nonatomic) int GetSet_Nonatomic_LateSynthesize;
+ at property(nonatomic) int Get_Nonatomic_LateSynthesize;
+ at property(nonatomic) int Set_Nonatomic_LateSynthesize;
+ at property(nonatomic) int None_Nonatomic_LateSynthesize;
+
+ at property(readonly) int GetSet_ReadOnly_LateSynthesize;
+ at property(readonly) int Get_ReadOnly_LateSynthesize;
+ at property(readonly) int Set_ReadOnly_LateSynthesize;
+ at property(readonly) int None_ReadOnly_LateSynthesize;
+ at property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly_LateSynthesize;
+ at property(nonatomic,readonly) int Get_Nonatomic_ReadOnly_LateSynthesize;
+ at property(nonatomic,readonly) int Set_Nonatomic_ReadOnly_LateSynthesize;
+ at property(nonatomic,readonly) int None_Nonatomic_ReadOnly_LateSynthesize;
+
+ at property(readonly) int GetSet_ReadWriteInExt_LateSynthesize;
+ at property(readonly) int Get_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}}
+ at property(readonly) int Set_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}}
+ at property(readonly) int None_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+
+// same as above, but with no @synthesize - must not warn
+ at property int GetSet_NoSynthesize;
+ at property int Get_NoSynthesize;
+ at property int Set_NoSynthesize;
+ at property int None_NoSynthesize;
+ at property(nonatomic) int GetSet_Nonatomic_NoSynthesize;
+ at property(nonatomic) int Get_Nonatomic_NoSynthesize;
+ at property(nonatomic) int Set_Nonatomic_NoSynthesize;
+ at property(nonatomic) int None_Nonatomic_NoSynthesize;
+
+ at property(readonly) int GetSet_ReadOnly_NoSynthesize;
+ at property(readonly) int Get_ReadOnly_NoSynthesize;
+ at property(readonly) int Set_ReadOnly_NoSynthesize;
+ at property(readonly) int None_ReadOnly_NoSynthesize;
+ at property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly_NoSynthesize;
+ at property(nonatomic,readonly) int Get_Nonatomic_ReadOnly_NoSynthesize;
+ at property(nonatomic,readonly) int Set_Nonatomic_ReadOnly_NoSynthesize;
+ at property(nonatomic,readonly) int None_Nonatomic_ReadOnly_NoSynthesize;
+
+ at property(readonly) int GetSet_ReadWriteInExt_NoSynthesize;
+ at property(readonly) int Get_ReadWriteInExt_NoSynthesize;
+ at property(readonly) int Set_ReadWriteInExt_NoSynthesize;
+ at property(readonly) int None_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt_NoSynthesize;
+
+ at end
+
+
+ at interface Foo ()
+
+ at property(readwrite) int GetSet_ReadWriteInExt;
+ at property(readwrite) int Get_ReadWriteInExt;
+ at property(readwrite) int Set_ReadWriteInExt;
+ at property(readwrite) int None_ReadWriteInExt;
+ at property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt;
+ at property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt;
+ at property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt;
+ at property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt;
+
+ at property(readwrite) int GetSet_ReadWriteInExt_LateSynthesize;
+ at property(readwrite) int Get_ReadWriteInExt_LateSynthesize;
+ at property(readwrite) int Set_ReadWriteInExt_LateSynthesize;
+ at property(readwrite) int None_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
+ at property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+ at property(readwrite) int GetSet_ReadWriteInExt_NoSynthesize;
+ at property(readwrite) int Get_ReadWriteInExt_NoSynthesize;
+ at property(readwrite) int Set_ReadWriteInExt_NoSynthesize;
+ at property(readwrite) int None_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
+ at property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt_NoSynthesize;
+
+ at end
+
+ at implementation Foo
+
+ at synthesize GetSet, Get, Set, None, GetSet_Nonatomic, Get_Nonatomic, Set_Nonatomic, None_Nonatomic;
+ at synthesize GetSet_ReadOnly, Get_ReadOnly, Set_ReadOnly, None_ReadOnly, GetSet_Nonatomic_ReadOnly, Get_Nonatomic_ReadOnly, Set_Nonatomic_ReadOnly, None_Nonatomic_ReadOnly;
+ at synthesize GetSet_ReadWriteInExt, Get_ReadWriteInExt, Set_ReadWriteInExt, None_ReadWriteInExt, GetSet_Nonatomic_ReadWriteInExt, Get_Nonatomic_ReadWriteInExt, Set_Nonatomic_ReadWriteInExt, None_Nonatomic_ReadWriteInExt;
+
+#define GET(x) \
+ -(int) x { return self->x; }
+#define SET(x) \
+ -(void) set##x:(int)value { self->x = value; }
+
+GET(GetSet)
+SET(GetSet)
+GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(GetSet_Nonatomic)
+SET(GetSet_Nonatomic)
+GET(Get_Nonatomic)
+SET(Set_Nonatomic)
+
+GET(GetSet_ReadOnly)
+SET(GetSet_ReadOnly)
+GET(Get_ReadOnly)
+SET(Set_ReadOnly)
+GET(GetSet_Nonatomic_ReadOnly)
+SET(GetSet_Nonatomic_ReadOnly)
+GET(Get_Nonatomic_ReadOnly)
+SET(Set_Nonatomic_ReadOnly)
+
+GET(GetSet_ReadWriteInExt)
+SET(GetSet_ReadWriteInExt)
+GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(GetSet_Nonatomic_ReadWriteInExt)
+SET(GetSet_Nonatomic_ReadWriteInExt)
+GET(Get_Nonatomic_ReadWriteInExt)
+SET(Set_Nonatomic_ReadWriteInExt)
+
+
+GET(GetSet_LateSynthesize)
+SET(GetSet_LateSynthesize)
+GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(GetSet_Nonatomic_LateSynthesize)
+SET(GetSet_Nonatomic_LateSynthesize)
+GET(Get_Nonatomic_LateSynthesize)
+SET(Set_Nonatomic_LateSynthesize)
+
+GET(GetSet_ReadOnly_LateSynthesize)
+SET(GetSet_ReadOnly_LateSynthesize)
+GET(Get_ReadOnly_LateSynthesize)
+SET(Set_ReadOnly_LateSynthesize)
+GET(GetSet_Nonatomic_ReadOnly_LateSynthesize)
+SET(GetSet_Nonatomic_ReadOnly_LateSynthesize)
+GET(Get_Nonatomic_ReadOnly_LateSynthesize)
+SET(Set_Nonatomic_ReadOnly_LateSynthesize)
+
+GET(GetSet_ReadWriteInExt_LateSynthesize)
+SET(GetSet_ReadWriteInExt_LateSynthesize)
+GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
+SET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
+GET(Get_Nonatomic_ReadWriteInExt_LateSynthesize)
+SET(Set_Nonatomic_ReadWriteInExt_LateSynthesize)
+
+
+GET(GetSet_NoSynthesize)
+SET(GetSet_NoSynthesize)
+GET(Get_NoSynthesize)
+SET(Set_NoSynthesize)
+GET(GetSet_Nonatomic_NoSynthesize)
+SET(GetSet_Nonatomic_NoSynthesize)
+GET(Get_Nonatomic_NoSynthesize)
+SET(Set_Nonatomic_NoSynthesize)
+
+GET(GetSet_ReadOnly_NoSynthesize)
+SET(GetSet_ReadOnly_NoSynthesize)
+GET(Get_ReadOnly_NoSynthesize)
+SET(Set_ReadOnly_NoSynthesize)
+GET(GetSet_Nonatomic_ReadOnly_NoSynthesize)
+SET(GetSet_Nonatomic_ReadOnly_NoSynthesize)
+GET(Get_Nonatomic_ReadOnly_NoSynthesize)
+SET(Set_Nonatomic_ReadOnly_NoSynthesize)
+
+GET(GetSet_ReadWriteInExt_NoSynthesize)
+SET(GetSet_ReadWriteInExt_NoSynthesize)
+GET(Get_ReadWriteInExt_NoSynthesize)
+SET(Set_ReadWriteInExt_NoSynthesize)
+GET(GetSet_Nonatomic_ReadWriteInExt_NoSynthesize)
+SET(GetSet_Nonatomic_ReadWriteInExt_NoSynthesize)
+GET(Get_Nonatomic_ReadWriteInExt_NoSynthesize)
+SET(Set_Nonatomic_ReadWriteInExt_NoSynthesize)
+
+
+// late synthesize - follows getter/setter implementations
+
+ at synthesize GetSet_LateSynthesize, Get_LateSynthesize, Set_LateSynthesize, None_LateSynthesize, GetSet_Nonatomic_LateSynthesize, Get_Nonatomic_LateSynthesize, Set_Nonatomic_LateSynthesize, None_Nonatomic_LateSynthesize;
+ at synthesize GetSet_ReadOnly_LateSynthesize, Get_ReadOnly_LateSynthesize, Set_ReadOnly_LateSynthesize, None_ReadOnly_LateSynthesize, GetSet_Nonatomic_ReadOnly_LateSynthesize, Get_Nonatomic_ReadOnly_LateSynthesize, Set_Nonatomic_ReadOnly_LateSynthesize, None_Nonatomic_ReadOnly_LateSynthesize;
+ at synthesize GetSet_ReadWriteInExt_LateSynthesize, Get_ReadWriteInExt_LateSynthesize, Set_ReadWriteInExt_LateSynthesize, None_ReadWriteInExt_LateSynthesize, GetSet_Nonatomic_ReadWriteInExt_LateSynthesize, Get_Nonatomic_ReadWriteInExt_LateSynthesize, Set_Nonatomic_ReadWriteInExt_LateSynthesize, None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+// no synthesize - use dynamic instead
+
+ at dynamic GetSet_NoSynthesize, Get_NoSynthesize, Set_NoSynthesize, None_NoSynthesize, GetSet_Nonatomic_NoSynthesize, Get_Nonatomic_NoSynthesize, Set_Nonatomic_NoSynthesize, None_Nonatomic_NoSynthesize;
+ at dynamic GetSet_ReadOnly_NoSynthesize, Get_ReadOnly_NoSynthesize, Set_ReadOnly_NoSynthesize, None_ReadOnly_NoSynthesize, GetSet_Nonatomic_ReadOnly_NoSynthesize, Get_Nonatomic_ReadOnly_NoSynthesize, Set_Nonatomic_ReadOnly_NoSynthesize, None_Nonatomic_ReadOnly_NoSynthesize;
+ at dynamic GetSet_ReadWriteInExt_NoSynthesize, Get_ReadWriteInExt_NoSynthesize, Set_ReadWriteInExt_NoSynthesize, None_ReadWriteInExt_NoSynthesize, GetSet_Nonatomic_ReadWriteInExt_NoSynthesize, Get_Nonatomic_ReadWriteInExt_NoSynthesize, Set_Nonatomic_ReadWriteInExt_NoSynthesize, None_Nonatomic_ReadWriteInExt_NoSynthesize;
+
+ at end
+
+/*
+// the following method should cause a warning along the lines of
+// :warning: Atomic property 'x' cannot pair a synthesized setter/getter with a manually implemented setter/getter
+- (void) setX: (int) aValue
+{
+ x = aValue;
+}
+
+// no warning 'cause this is nonatomic
+- (void) setY: (int) aValue
+{
+ y = aValue;
+}
+
+// the following method should cause a warning along the lines of
+// :warning: Atomic property 'x' cannot pair a synthesized setter/getter with a manually implemented setter/getter
+- (int) j
+{
+ return j;
+}
+
+// no warning 'cause this is nonatomic
+- (int) k
+{
+ return k;
+}
+ at end
+*/
+int main (int argc, const char * argv[]) {
+ return 0;
+}
Modified: cfe/trunk/test/SemaObjC/property-category-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-1.m?rev=86887&r1=86886&r2=86887&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-1.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-1.m Wed Nov 11 16:40:11 2009
@@ -24,6 +24,7 @@
- (void) myAnotherobjectSetter : (int)val {
_Anotherobject = val;
}
+- (int) Anotherobject { return _Anotherobject; }
@end
int main(int argc, char **argv) {
More information about the cfe-commits
mailing list