llvm-project/clang/test/SemaObjC/tentative-property-decl.m
Fariborz Jahanian 059021a369 Objective-C. Do not issue warning when 'readonly'
property declaration has a memory management
attribute (retain, copy, etc.). Sich properties
are usually overridden to become 'readwrite'
via a class extension (which require the memory
management attribute specified). In the absence of class
extension override, memory management attribute is
needed to produce correct Code Gen. for the
property getter in any case and this warning becomes
confusing to user. // rdar://15641300

llvm-svn: 197251
2013-12-13 18:19:59 +00:00

49 lines
1.1 KiB
Objective-C

// RUN: %clang_cc1 -fsyntax-only -Weverything -verify %s
// expected-no-diagnostics
// rdar://11656982
/** A property may not be both 'readonly' and having a memory management attribute
(copy/retain/etc.). But, property declaration in primary class and protcols
are tentative as they may be overridden into a 'readwrite' property in class
extensions. So, do not issue any warning on 'readonly' and memory management
attributes in a property.
*/
@interface Super {
}
@end
@class NSString;
@interface MyClass : Super
@property(nonatomic, copy, readonly) NSString *prop;
@property(nonatomic, copy, readonly) id warnProp;
@end
@interface MyClass ()
@property(nonatomic, copy, readwrite) NSString *prop;
@end
@implementation MyClass
@synthesize prop;
@synthesize warnProp;
@end
@protocol P
@property(nonatomic, copy, readonly) NSString *prop;
@property(nonatomic, copy, readonly) id warnProp;
@end
@interface YourClass : Super <P>
@end
@interface YourClass ()
@property(nonatomic, copy, readwrite) NSString *prop;
@end
@implementation YourClass
@synthesize prop;
@synthesize warnProp;
@end