1 __attribute__((objc_root_class
))
5 __attribute__((objc_root_class
))
11 void f1(int *x
); // expected-warning{{pointer is missing a nullability type specifier}}
12 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
13 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
15 typedef struct __attribute__((objc_bridge(NSError
))) __CFError
*CFErrorRef
;
16 typedef NSError
*NSErrorPtr
;
17 typedef NSError
**NSErrorPtrPtr
;
18 typedef CFErrorRef
*CFErrorRefPtr
;
21 typedef int (^block_ptr
)(int, int);
23 #pragma clang assume_nonnull begin
27 void f4(int (^block
)(int, int));
30 void f7(int * _Nullable x
);
31 void f8(A
* _Nullable obj
);
32 void f9(int X::* mem_ptr
);
33 void f10(int (X::*mem_func
)(int, int));
34 void f11(int X::* _Nullable mem_ptr
);
35 void f12(int (X::* _Nullable mem_func
)(int, int));
40 int * _Null_unspecified
f15(void);
41 A
* _Null_unspecified
f16(void);
42 void f17(CFErrorRef
*error
); // expected-note{{no known conversion from 'A * _Nonnull' to 'CFErrorRef _Nullable * _Nullable' (aka '__CFError **') for 1st argument}}
43 void f18(A
**); // expected-warning 2{{pointer is missing a nullability type specifier}}
44 // expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
45 // expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
46 void f19(CFErrorRefPtr error
); // expected-warning{{pointer is missing a nullability type specifier}}
47 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
48 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
50 void g1(int (^)(int, int));
51 void g2(int (^ *bp
)(int, int)); // expected-warning{{block pointer is missing a nullability type specifier}}
52 // expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
53 // expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
54 // expected-warning@-3{{pointer is missing a nullability type specifier}}
55 // expected-note@-4{{insert '_Nullable' if the pointer may be null}}
56 // expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
57 void g3(block_ptr
*bp
); // expected-warning{{block pointer is missing a nullability type specifier}}
58 // expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
59 // expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
60 // expected-warning@-3{{pointer is missing a nullability type specifier}}
61 // expected-note@-4{{insert '_Nullable' if the pointer may be null}}
62 // expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
63 void g4(int (*fp
)(int, int));
64 void g5(int (**fp
)(int, int)); // expected-warning 2{{pointer is missing a nullability type specifier}}
65 // expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
66 // expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
68 @interface
A(Pragmas1
)
69 + (instancetype
)aWithA
:(A
*)a
;
70 - (A
*)method1
:(A_ptr
)ptr
;
71 - (null_unspecified A
*)method2
;
72 - (void)method3
:(NSError
**)error
; // expected-note{{passing argument to parameter 'error' here}}
73 - (void)method4
:(NSErrorPtr
*)error
; // expected-note{{passing argument to parameter 'error' here}}
74 - (void)method5
:(NSErrorPtrPtr
)error
;
75 // expected-warning@-1{{pointer is missing a nullability type specifier}}
76 // expected-note@-2{{insert '_Nullable' if the pointer may be null}}
77 // expected-note@-3{{insert '_Nonnull' if the pointer should never be null}}
80 @property NSError
**anError
; // expected-warning 2{{pointer is missing a nullability type specifier}}
81 // expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
82 // expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
87 // typedefs not inferred _Nonnull
88 typedef int *int_ptr_2
;
90 typedef int * // expected-warning{{pointer is missing a nullability type specifier}}
91 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
92 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
95 static inline void f30(void) {
96 float *fp
= global_int_ptr
; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int * _Nonnull'}}
99 float *fp2
= ip2
; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int_ptr_2' (aka 'int *')}}
102 float *fp3
= ipp
; // expected-error{{lvalue of type 'int_ptr_ptr' (aka 'int **')}}
112 #pragma clang assume_nonnull end
114 void f20(A
*a
); // expected-warning{{pointer is missing a nullability type specifier}}
115 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
116 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
117 void f21(int_ptr x
); // expected-warning{{pointer is missing a nullability type specifier}}
118 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
119 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
120 void f22(A_ptr y
); // expected-warning{{pointer is missing a nullability type specifier}}
121 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
122 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
123 void f23(int_ptr _Nullable x
);
124 void f24(A_ptr _Nullable y
);
125 void f25(int_ptr_2 x
); // expected-warning{{pointer is missing a nullability type specifier}}
126 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
127 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
129 @interface
A(OutsidePragmas1
)
130 + (instancetype
)aWithInt
:(int)value
; // expected-warning{{pointer is missing a nullability type specifier}}
131 // expected-note@-1{{insert '_Nullable' if the pointer may be null}}
132 // expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}