xref: /aosp_15_r20/external/clang/test/SemaObjC/property-noninherited-availability-attr.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8.0 -fsyntax-only -verify %s
2*67e74705SXin Li
3*67e74705SXin Li// This test case shows that 'availability' and 'deprecated' do not inherit
4*67e74705SXin Li// when a property is redeclared in a subclass.  This is intentional.
5*67e74705SXin Li
6*67e74705SXin Li@interface NSObject @end
7*67e74705SXin Li@protocol myProtocol
8*67e74705SXin Li@property int myProtocolProperty __attribute__((availability(macosx,introduced=10.7,deprecated=10.8))); // expected-note {{'myProtocolProperty' has been explicitly marked deprecated here}} \
9*67e74705SXin Li                                                                                                        // expected-note {{property 'myProtocolProperty' is declared deprecated here}}
10*67e74705SXin Li@end
11*67e74705SXin Li
12*67e74705SXin Li@interface Foo : NSObject
13*67e74705SXin Li@property int myProperty __attribute__((availability(macosx,introduced=10.7,deprecated=10.8)));  // expected-note 2 {{'myProperty' has been explicitly marked deprecated here}} \
14*67e74705SXin Li								// expected-note {{property 'myProperty' is declared deprecated here}}
15*67e74705SXin Li@end
16*67e74705SXin Li
17*67e74705SXin Li@interface Bar : Foo <myProtocol>
18*67e74705SXin Li@property int myProperty;
19*67e74705SXin Li@property int myProtocolProperty;
20*67e74705SXin Li@end
21*67e74705SXin Li
22*67e74705SXin Livoid test(Foo *y, Bar *x, id<myProtocol> z) {
23*67e74705SXin Li  y.myProperty = 0; // expected-warning {{'myProperty' is deprecated: first deprecated in macOS 10.8}}
24*67e74705SXin Li  (void)[y myProperty];   // expected-warning {{'myProperty' is deprecated: first deprecated in macOS 10.8}}
25*67e74705SXin Li
26*67e74705SXin Li  x.myProperty = 1; // no-warning
27*67e74705SXin Li  (void)[x myProperty]; // no-warning
28*67e74705SXin Li
29*67e74705SXin Li  x.myProtocolProperty = 0; // no-warning
30*67e74705SXin Li
31*67e74705SXin Li  (void)[x myProtocolProperty]; // no-warning
32*67e74705SXin Li  (void)[z myProtocolProperty]; // expected-warning {{'myProtocolProperty' is deprecated: first deprecated in macOS 10.8}}
33*67e74705SXin Li}
34