134 lines · c
1__attribute__((objc_root_class))2@interface NSError3@end4 5__attribute__((objc_root_class))6@interface A7@end8 9struct X { };10 11void 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}}14 15typedef struct __attribute__((objc_bridge(NSError))) __CFError *CFErrorRef;16typedef NSError *NSErrorPtr;17typedef NSError **NSErrorPtrPtr;18typedef CFErrorRef *CFErrorRefPtr;19typedef int *int_ptr;20typedef A *A_ptr;21typedef int (^block_ptr)(int, int);22 23#pragma clang assume_nonnull begin24 25void f2(int *x);26void f3(A* obj);27void f4(int (^block)(int, int));28void f5(int_ptr x);29void f6(A_ptr obj);30void f7(int * _Nullable x);31void f8(A * _Nullable obj);32void f9(int X::* mem_ptr);33void f10(int (X::*mem_func)(int, int));34void f11(int X::* _Nullable mem_ptr);35void f12(int (X::* _Nullable mem_func)(int, int));36 37int_ptr f13(void);38A *f14(void);39 40int * _Null_unspecified f15(void);41A * _Null_unspecified f16(void);42void f17(CFErrorRef *error); // expected-note{{no known conversion from 'A * _Nonnull' to 'CFErrorRef _Nullable * _Nullable' (aka 'struct __CFError **') for 1st argument}}43void 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}}46void 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}}49 50void g1(int (^)(int, int));51void 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}}57void 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}}63void g4(int (*fp)(int, int));64void 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}}67 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}}78 79@property A *aProp;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}}83@end84 85int *global_int_ptr;86 87// typedefs not inferred _Nonnull88typedef int *int_ptr_2;89 90typedef 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}}93 *int_ptr_ptr;94 95static 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'}}97 98 int_ptr_2 ip2;99 float *fp2 = ip2; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int_ptr_2' (aka 'int *')}}100 101 int_ptr_ptr ipp;102 float *fp3 = ipp; // expected-error{{lvalue of type 'int_ptr_ptr' (aka 'int **')}}103}104 105@interface AA : A {106@public107 id ivar1;108 _Nonnull id ivar2;109}110@end111 112#pragma clang assume_nonnull end113 114void 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}}117void 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}}120void 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}}123void f23(int_ptr _Nullable x);124void f24(A_ptr _Nullable y);125void 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}}128 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}}133@end134