Fariborz Jahanian | cea06d2 | 2012-06-20 22:57:42 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Weverything -verify %s |
| 2 | // rdar://11656982 |
| 3 | /** Normally, a property cannot be both 'readonly' and having a "write" attribute |
| 4 | (copy/retain/etc.). But, property declaration in primary class and protcols |
| 5 | are tentative as they may be overridden into a 'readwrite' property in class |
| 6 | extensions. Postpone diagnosing such warnings until the class implementation |
| 7 | is seen. |
| 8 | */ |
| 9 | |
| 10 | @interface Super { |
| 11 | } |
| 12 | @end |
| 13 | |
| 14 | @class NSString; |
| 15 | |
| 16 | @interface MyClass : Super |
| 17 | @property(nonatomic, copy, readonly) NSString *prop; |
Fariborz Jahanian | c78ff27 | 2012-06-20 23:18:57 +0000 | [diff] [blame] | 18 | @property(nonatomic, copy, readonly) id warnProp; // expected-warning {{property attributes 'readonly' and 'copy' are mutually exclusive}} |
Fariborz Jahanian | cea06d2 | 2012-06-20 22:57:42 +0000 | [diff] [blame] | 19 | @end |
| 20 | |
| 21 | @interface MyClass () |
| 22 | @property(nonatomic, copy, readwrite) NSString *prop; |
| 23 | @end |
| 24 | |
| 25 | @implementation MyClass |
| 26 | @synthesize prop; |
Fariborz Jahanian | c78ff27 | 2012-06-20 23:18:57 +0000 | [diff] [blame] | 27 | @synthesize warnProp; |
Fariborz Jahanian | cea06d2 | 2012-06-20 22:57:42 +0000 | [diff] [blame] | 28 | @end |
| 29 | |
| 30 | |
| 31 | @protocol P |
| 32 | @property(nonatomic, copy, readonly) NSString *prop; |
Fariborz Jahanian | c78ff27 | 2012-06-20 23:18:57 +0000 | [diff] [blame] | 33 | @property(nonatomic, copy, readonly) id warnProp; // expected-warning {{property attributes 'readonly' and 'copy' are mutually exclusive}} |
Fariborz Jahanian | cea06d2 | 2012-06-20 22:57:42 +0000 | [diff] [blame] | 34 | @end |
| 35 | |
| 36 | @interface YourClass : Super <P> |
| 37 | @end |
| 38 | |
| 39 | @interface YourClass () |
| 40 | @property(nonatomic, copy, readwrite) NSString *prop; |
| 41 | @end |
| 42 | |
| 43 | @implementation YourClass |
| 44 | @synthesize prop; |
Fariborz Jahanian | c78ff27 | 2012-06-20 23:18:57 +0000 | [diff] [blame] | 45 | @synthesize warnProp; |
Fariborz Jahanian | cea06d2 | 2012-06-20 22:57:42 +0000 | [diff] [blame] | 46 | @end |
| 47 | |