2015-06-20 02:25:57 +08:00
__attribute__ ( ( objc_root_class ) )
@ interface NSError
@ end
__attribute__ ( ( objc_root_class ) )
@ interface A
@ end
struct X { } ;
2015-06-20 02:27:45 +08:00
void f1 ( int * x ) ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
typedef struct __attribute__ ( ( objc_bridge ( NSError ) ) ) __CFError * CFErrorRef ;
typedef NSError * NSErrorPtr ;
typedef NSError * * NSErrorPtrPtr ;
typedef CFErrorRef * CFErrorRefPtr ;
typedef int * int_ptr ;
typedef A * A_ptr ;
typedef int ( ^ block_ptr ) ( int , int ) ;
# pragma clang assume_nonnull begin
void f2 ( int * x ) ;
void f3 ( A * obj ) ;
void f4 ( int ( ^ block ) ( int , int ) ) ;
void f5 ( int_ptr x ) ;
void f6 ( A_ptr obj ) ;
2015-06-25 06:02:08 +08:00
void f7 ( int * _Nullable x ) ;
void f8 ( A * _Nullable obj ) ;
2015-06-20 02:25:57 +08:00
void f9 ( int X : : * mem_ptr ) ;
void f10 ( int ( X : : * mem_func ) ( int , int ) ) ;
2015-06-25 06:02:08 +08:00
void f11 ( int X : : * _Nullable mem_ptr ) ;
void f12 ( int ( X : : * _Nullable mem_func ) ( int , int ) ) ;
2015-06-20 02:25:57 +08:00
int_ptr f13 ( void ) ;
A * f14 ( void ) ;
2015-06-25 06:02:08 +08:00
int * _Null_unspecified f15 ( void ) ;
A * _Null_unspecified f16 ( void ) ;
void f17 ( CFErrorRef * error ) ; // expected-note{{no known conversion from 'A * _Nonnull' to 'CFErrorRef _Nullable * _Nullable' (aka '__CFError **') for 1st argument}}
2015-06-20 02:27:45 +08:00
void f18 ( A * * ) ; // expected-warning 2{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:27:45 +08:00
void f19 ( CFErrorRefPtr error ) ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
void g1 ( int ( ^ ) ( int , int ) ) ;
2015-06-20 02:27:45 +08:00
void g2 ( int ( ^ * bp ) ( int , int ) ) ; // expected-warning{{block pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
// expected-warning@-3{{pointer is missing a nullability type specifier}}
// expected-note@-4{{insert '_Nullable' if the pointer may be null}}
// expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:27:45 +08:00
void g3 ( block_ptr * bp ) ; // expected-warning{{block pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
// expected-warning@-3{{pointer is missing a nullability type specifier}}
// expected-note@-4{{insert '_Nullable' if the pointer may be null}}
// expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
void g4 ( int ( * fp ) ( int , int ) ) ;
2015-06-20 02:27:45 +08:00
void g5 ( int ( * * fp ) ( int , int ) ) ; // expected-warning 2{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
@ interface A ( Pragmas1 )
+ ( instancetype ) aWithA : ( A * ) a ;
- ( A * ) method1 : ( A_ptr ) ptr ;
- ( null_unspecified A * ) method2 ;
- ( void ) method3 : ( NSError * * ) error ; // expected-note{{passing argument to parameter 'error' here}}
- ( void ) method4 : ( NSErrorPtr * ) error ; // expected-note{{passing argument to parameter 'error' here}}
- ( void ) method5 : ( NSErrorPtrPtr ) error ;
2015-06-20 02:27:45 +08:00
// expected-warning@-1{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-2{{insert '_Nullable' if the pointer may be null}}
// expected-note@-3{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
@ property A * aProp ;
2015-06-20 02:27:45 +08:00
@ property NSError * * anError ; // expected-warning 2{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
@ end
int * global_int_ptr ;
2015-06-25 06:02:08 +08:00
// typedefs not inferred _Nonnull
2015-06-20 02:25:57 +08:00
typedef int * int_ptr_2 ;
2015-06-20 02:27:45 +08:00
typedef int * // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
* int_ptr_ptr ;
static inline void f30 ( void ) {
2015-06-25 06:02:08 +08:00
float * fp = global_int_ptr ; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int * _Nonnull'}}
2015-06-20 02:25:57 +08:00
int_ptr_2 ip2 ;
float * fp2 = ip2 ; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int_ptr_2' (aka 'int *')}}
int_ptr_ptr ipp ;
float * fp3 = ipp ; // expected-error{{lvalue of type 'int_ptr_ptr' (aka 'int **')}}
}
@ interface AA : A {
@ public
id ivar1 ;
2015-06-25 06:02:08 +08:00
_Nonnull id ivar2 ;
2015-06-20 02:25:57 +08:00
}
@ end
# pragma clang assume_nonnull end
2015-06-20 02:27:45 +08:00
void f20 ( A * a ) ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:27:45 +08:00
void f21 ( int_ptr x ) ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:27:45 +08:00
void f22 ( A_ptr y ) ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-25 06:02:08 +08:00
void f23 ( int_ptr _Nullable x ) ;
void f24 ( A_ptr _Nullable y ) ;
2015-06-20 02:27:45 +08:00
void f25 ( int_ptr_2 x ) ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
@ interface A ( OutsidePragmas1 )
2015-06-20 02:27:45 +08:00
+ ( instancetype ) aWithInt : ( int ) value ; // expected-warning{{pointer is missing a nullability type specifier}}
2016-12-20 04:58:20 +08:00
// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
2015-06-20 02:25:57 +08:00
@ end