]> granicus.if.org Git - clang/commitdiff
objective-C: peroform property attribute consistency
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 17 Sep 2012 20:57:19 +0000 (20:57 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 17 Sep 2012 20:57:19 +0000 (20:57 +0000)
checking on property declared in class extension.
// rdar://12214070

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

lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/property-in-class-extension-1.m
test/SemaObjCXX/property-synthesis-error.mm

index 4d2fb777e2164ea1ceaaf7e4295ee699fade0018..131c48f0125ca5317da864a9db959d4bc114091e 100644 (file)
@@ -349,6 +349,7 @@ Sema::HandlePropertyInClassExtension(Scope *S,
       Diag(AtLoc, 
           diag::err_type_mismatch_continuation_class) << PDecl->getType();
       Diag(PIDecl->getLocation(), diag::note_property_declare);
+      return 0;
     }
   }
     
@@ -409,6 +410,7 @@ Sema::HandlePropertyInClassExtension(Scope *S,
     Diag(AtLoc, diag)
       << CCPrimary->getDeclName();
     Diag(PIDecl->getLocation(), diag::note_property_declare);
+    return 0;
   }
   *isOverridingProperty = true;
   // Make sure setter decl is synthesized, and added to primary class's list.
@@ -417,7 +419,7 @@ Sema::HandlePropertyInClassExtension(Scope *S,
   PDecl->setSetterMethodDecl(PIDecl->getSetterMethodDecl());
   if (ASTMutationListener *L = Context.getASTMutationListener())
     L->AddedObjCPropertyInClassExtension(PDecl, PIDecl, CDecl);
-  return 0;
+  return PDecl;
 }
 
 ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
index dfa5e718a4259a8afd3979b66de74f4df332ea06..18eae24cc1bef725f0afd062ceb2ef96d6b03709 100644 (file)
 
 @property (nonatomic, copy) NSString* addingMemoryModel;
 @property (nonatomic, copy) NSString* matchingMemoryModel;
-@property () NSString* addingNoNewMemoryModel;
-@property () NSString* none;
-@property (readwrite) NSString* none1;
+@property () NSString* addingNoNewMemoryModel; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \
+                                               // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}}
+@property () NSString* none; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \
+                                               // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}}
+@property (readwrite, retain) NSString* none1;
 
 @property (retain) NSString* changeMemoryModel; // expected-warning {{property attribute in class extension does not match the primary class}}
-@property () __weak id weak_prop;
-@property (readwrite) __weak id weak_prop1;
+@property () __weak id weak_prop; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \
+                                  // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}}
+@property (readwrite) __weak id weak_prop1; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}\
+                                           // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}}
 
-@property () NSString* assignProperty;
+@property (assign, readwrite) NSString* assignProperty;
 @property (assign) NSString* readonlyProp;
 @end
 
+// rdar://12214070
+@interface radar12214070
+@property (nonatomic, atomic, readonly) float propertyName; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}}
+@end
+
+@interface radar12214070 ()
+@property (atomic, nonatomic, readonly, readwrite) float propertyName; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}} \
+               // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}}
+@end
+
index 4f64a3a3385e0ad3dac79ba07140e6ca8778f996..1d93523b4c9903d29813a533698f98d44ce70cf4 100644 (file)
@@ -16,7 +16,7 @@
 
 @interface MyClass ()
 
-@property (readwrite) NSMutableArray * array;
+@property (readwrite, retain) NSMutableArray * array;
 
 @end