xref: /llvm-project/clang/test/SemaObjCXX/Inputs/nullability-consistency-7.h (revision 06dd406e27b4d43e202b1a8a9782896f80cb0370)
1 #ifndef SOMEKIT_H
2 #define SOMEKIT_H
3 
4 __attribute__((objc_root_class))
5 #ifndef NS_ASSUME_NONNULL_BEGIN
6 #if __has_feature(assume_nonnull)
7 #define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
8 #define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
9 #else
10 #define NS_ASSUME_NONNULL_BEGIN
11 #define NS_ASSUME_NONNULL_END
12 #endif
13 #endif
14 
15 NS_ASSUME_NONNULL_BEGIN
16 
17 @interface A
18 -(null_unspecified A*)transform:(null_unspecified A*)input __attribute__((unavailable("anything but this")));
19 -(A*)transform:(A*)input integer:(int)integer;
20 
21 @property (null_unspecified, nonatomic, readonly, retain) A* someA;
22 @property (null_unspecified, nonatomic, retain) A* someOtherA;
23 
24 @property (nonatomic) int intValue __attribute__((unavailable("wouldn't work anyway")));
25 @end
26 
27 NS_ASSUME_NONNULL_END
28 
29 
30 __attribute__((unavailable("just don't")))
31 @interface B : A
32 @end
33 
34 @interface C : A
35 - (instancetype)init; // expected-warning{{pointer is missing a nullability type specifier}}
36 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
37 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
38 - (instancetype)initWithA:( A*)a __attribute__((objc_designated_initializer)); // expected-warning 2{{pointer is missing a nullability type specifier}}
39 // expected-note@-1 2{{insert '_Nullable' if the pointer may be null}}
40 // expected-note@-2 2{{insert '_Nonnull' if the pointer should never be null}}
41 @end
42 
43 #endif
44 
45