diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-04-06 00:34:27 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-04-06 00:34:27 +0000 |
commit | cb3443925f967b5d51e582b39e28f67d41d73199 (patch) | |
tree | d65c1811a579ca469d09bfa178f28790081d5840 /test/SemaObjC | |
parent | 24cac5a4847b9e4673afb9fd02701f273097f57a (diff) |
Rework how ObjC method inherit deprecated/availability.
New rule:
- Method decls in @implementation are considered "redeclarations"
and inherit deprecated/availability from the @interface.
- All other cases are consider overrides, which do not inherit
deprecated/availability. For example:
(a) @interface redeclares a method in an adopted protocol.
(b) A subclass redeclares a method in a superclass.
(c) A protocol redeclares a method from another protocol it adopts.
The idea is that API authors should have the ability to easily
move availability/deprecated up and down a class/protocol hierarchy.
A redeclaration means that the availability/deprecation is a blank
slate.
Fixes <rdar://problem/13574571>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178937 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjC')
-rw-r--r-- | test/SemaObjC/attr-availability.m | 4 | ||||
-rw-r--r-- | test/SemaObjC/property-deprecated-warning.m | 38 | ||||
-rw-r--r-- | test/SemaObjC/property-noninherited-availability-attr.m | 14 |
3 files changed, 37 insertions, 19 deletions
diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m index bf7ef19bea..5fe2b62d07 100644 --- a/test/SemaObjC/attr-availability.m +++ b/test/SemaObjC/attr-availability.m @@ -17,7 +17,7 @@ // rdar://11475360 @interface B : A -- (void)method; // expected-note {{method 'method' declared here}} +- (void)method; // NOTE: we expect 'method' to *not* inherit availability. - (void)overridden __attribute__((availability(macosx,introduced=10.4))); // expected-warning{{overriding method introduced after overridden method on OS X (10.4 vs. 10.3)}} - (void)overridden2 __attribute__((availability(macosx,introduced=10.2))); - (void)overridden3 __attribute__((availability(macosx,deprecated=10.4))); @@ -28,7 +28,7 @@ void f(A *a, B *b) { [a method]; // expected-warning{{'method' is deprecated: first deprecated in OS X 10.2}} - [b method]; // expected-warning {{'method' is deprecated: first deprecated in OS X 10.2}} + [b method]; // no-warning [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}} [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}} } diff --git a/test/SemaObjC/property-deprecated-warning.m b/test/SemaObjC/property-deprecated-warning.m index aa7b764fab..7e10356ac5 100644 --- a/test/SemaObjC/property-deprecated-warning.m +++ b/test/SemaObjC/property-deprecated-warning.m @@ -5,37 +5,51 @@ typedef signed char BOOL; @protocol P -@property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note 2 {{property 'ptarget' is declared deprecated here}} +@property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'ptarget' is declared deprecated here}} expected-note {{method 'ptarget' declared here}} @end @protocol P1<P> -- (void)setPtarget:(id)arg; // expected-note {{method 'setPtarget:' declared here}} +- (void)setPtarget:(id)arg; @end @interface UITableViewCell<P1> -@property(nonatomic,assign) id target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'target' is declared deprecated here}} +@property(nonatomic,assign) id target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'target' is declared deprecated here}} expected-note {{method 'setTarget:' declared here}} @end @interface PSTableCell : UITableViewCell - - (void)setTarget:(id)target; // expected-note {{method 'setTarget:' declared here}} + - (void)setTarget:(id)target; @end @interface UITableViewCell(UIDeprecated) -@property(nonatomic,assign) id dep_target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{method 'dep_target' declared here}} \ - // expected-note 2 {{property 'dep_target' is declared deprecated here}} \ - // expected-note {{method 'setDep_target:' declared here}} +@property(nonatomic,assign) id dep_target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note 2 {{method 'dep_target' declared here}} \ + // expected-note 4 {{property 'dep_target' is declared deprecated here}} \ + // expected-note 2 {{method 'setDep_target:' declared here}} @end @implementation PSTableCell - (void)setTarget:(id)target {}; - (void)setPtarget:(id)val {}; - (void) Meth { + [self setTarget: (id)0]; // no-warning + [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \ + // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}} + + [self setPtarget: (id)0]; // no-warning +} +@end + +@implementation UITableViewCell +@synthesize target; +@synthesize ptarget; +- (void)setPtarget:(id)val {}; +- (void)setTarget:(id)target {}; +- (void) Meth { [self setTarget: (id)0]; // expected-warning {{'setTarget:' is deprecated: first deprecated in iOS 3.0}} [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \ // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}} - [self setPtarget: (id)0]; // expected-warning {{setPtarget:' is deprecated: first deprecated in iOS 3.0}} + [self setPtarget: (id)0]; // no-warning } @end @@ -56,9 +70,11 @@ void testCustomAccessorNames(CustomAccessorNames *obj) { @end @interface ProtocolInCategory (TheCategory) <P1> -- (id)ptarget; // expected-note {{method 'ptarget' declared here}} +- (id)ptarget; @end -id useDeprecatedProperty(ProtocolInCategory *obj) { - return [obj ptarget]; // expected-warning {{'ptarget' is deprecated: first deprecated in iOS 3.0}} +id useDeprecatedProperty(ProtocolInCategory *obj, id<P> obj2, int flag) { + if (flag) + return [obj ptarget]; // no-warning + return [obj2 ptarget]; // expected-warning {{'ptarget' is deprecated: first deprecated in iOS 3.0}} } diff --git a/test/SemaObjC/property-noninherited-availability-attr.m b/test/SemaObjC/property-noninherited-availability-attr.m index 79cdd3e476..0c2a5d3853 100644 --- a/test/SemaObjC/property-noninherited-availability-attr.m +++ b/test/SemaObjC/property-noninherited-availability-attr.m @@ -5,7 +5,8 @@ @interface NSObject @end @protocol myProtocol -@property int myProtocolProperty __attribute__((availability(macosx,introduced=10.7,deprecated=10.8))); +@property int myProtocolProperty __attribute__((availability(macosx,introduced=10.7,deprecated=10.8))); // expected-note {{method 'myProtocolProperty' declared here}} \ + // expected-note {{property 'myProtocolProperty' is declared deprecated here}} @end @interface Foo : NSObject @@ -15,18 +16,19 @@ @end @interface Bar : Foo <myProtocol> -@property int myProperty; // expected-note {{'myProperty' declared here}} -@property int myProtocolProperty; // expected-note {{'myProtocolProperty' declared here}} +@property int myProperty; +@property int myProtocolProperty; @end -void test(Foo *y, Bar *x) { +void test(Foo *y, Bar *x, id<myProtocol> z) { y.myProperty = 0; // expected-warning {{'myProperty' is deprecated: first deprecated in OS X 10.8}} [y myProperty]; // expected-warning {{'myProperty' is deprecated: first deprecated in OS X 10.8}} x.myProperty = 1; // no-warning - [x myProperty]; // expected-warning {{'myProperty' is deprecated: first deprecated in OS X 10.8}} + [x myProperty]; // no-warning x.myProtocolProperty = 0; // no-warning - [x myProtocolProperty]; // expected-warning {{'myProtocolProperty' is deprecated: first deprecated in OS X 10.8}} + [x myProtocolProperty]; // no-warning + [z myProtocolProperty]; // expected-warning {{'myProtocolProperty' is deprecated: first deprecated in OS X 10.8}} } |