Home | History | Annotate | Download | only in Inputs
      1 __attribute__((objc_root_class))
      2 @interface NSError
      3 @end
      4 
      5 __attribute__((objc_root_class))
      6 @interface A
      7 @end
      8 
      9 struct X { };
     10 
     11 void f1(int *x); // expected-warning{{pointer is missing a nullability type specifier}}
     12 
     13 typedef struct __attribute__((objc_bridge(NSError))) __CFError *CFErrorRef;
     14 typedef NSError *NSErrorPtr;
     15 typedef NSError **NSErrorPtrPtr;
     16 typedef CFErrorRef *CFErrorRefPtr;
     17 typedef int *int_ptr;
     18 typedef A *A_ptr;
     19 typedef int (^block_ptr)(int, int);
     20 
     21 #pragma clang assume_nonnull begin
     22 
     23 void f2(int *x);
     24 void f3(A* obj);
     25 void f4(int (^block)(int, int));
     26 void f5(int_ptr x);
     27 void f6(A_ptr obj);
     28 void f7(int * _Nullable x);
     29 void f8(A * _Nullable obj);
     30 void f9(int X::* mem_ptr);
     31 void f10(int (X::*mem_func)(int, int));
     32 void f11(int X::* _Nullable mem_ptr);
     33 void f12(int (X::* _Nullable mem_func)(int, int));
     34 
     35 int_ptr f13(void);
     36 A *f14(void);
     37 
     38 int * _Null_unspecified f15(void);
     39 A * _Null_unspecified f16(void);
     40 void f17(CFErrorRef *error); // expected-note{{no known conversion from 'A * _Nonnull' to 'CFErrorRef  _Nullable * _Nullable' (aka '__CFError **') for 1st argument}}
     41 void f18(A **); // expected-warning 2{{pointer is missing a nullability type specifier}}
     42 void f19(CFErrorRefPtr error); // expected-warning{{pointer is missing a nullability type specifier}}
     43 
     44 void g1(int (^)(int, int));
     45 void g2(int (^ *bp)(int, int)); // expected-warning{{block pointer is missing a nullability type specifier}}
     46 // expected-warning@-1{{pointer is missing a nullability type specifier}}
     47 void g3(block_ptr *bp); // expected-warning{{block pointer is missing a nullability type specifier}}
     48 // expected-warning@-1{{pointer is missing a nullability type specifier}}
     49 void g4(int (*fp)(int, int));
     50 void g5(int (**fp)(int, int)); // expected-warning 2{{pointer is missing a nullability type specifier}}
     51 
     52 @interface A(Pragmas1)
     53 + (instancetype)aWithA:(A *)a;
     54 - (A *)method1:(A_ptr)ptr;
     55 - (null_unspecified A *)method2;
     56 - (void)method3:(NSError **)error; // expected-note{{passing argument to parameter 'error' here}}
     57 - (void)method4:(NSErrorPtr *)error; // expected-note{{passing argument to parameter 'error' here}}
     58 - (void)method5:(NSErrorPtrPtr)error;
     59 // expected-warning@-1{{pointer is missing a nullability type specifier}}
     60 
     61 @property A *aProp;
     62 @property NSError **anError; // expected-warning 2{{pointer is missing a nullability type specifier}}
     63 @end
     64 
     65 int *global_int_ptr;
     66 
     67 // typedefs not inferred _Nonnull
     68 typedef int *int_ptr_2;
     69 
     70 typedef int * // expected-warning{{pointer is missing a nullability type specifier}}
     71             *int_ptr_ptr;
     72 
     73 static inline void f30(void) {
     74   float *fp = global_int_ptr; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int * _Nonnull'}}
     75 
     76   int_ptr_2 ip2;
     77   float *fp2 = ip2; // expected-error{{cannot initialize a variable of type 'float *' with an lvalue of type 'int_ptr_2' (aka 'int *')}}
     78 
     79   int_ptr_ptr ipp;
     80   float *fp3 = ipp; // expected-error{{lvalue of type 'int_ptr_ptr' (aka 'int **')}}
     81 }
     82 
     83 @interface AA : A {
     84 @public
     85   id ivar1;
     86   _Nonnull id ivar2;
     87 }
     88 @end
     89 
     90 #pragma clang assume_nonnull end
     91 
     92 void f20(A *a); // expected-warning{{pointer is missing a nullability type specifier}}
     93 void f21(int_ptr x); // expected-warning{{pointer is missing a nullability type specifier}}
     94 void f22(A_ptr y); // expected-warning{{pointer is missing a nullability type specifier}}
     95 void f23(int_ptr _Nullable x);
     96 void f24(A_ptr _Nullable y);
     97 void f25(int_ptr_2 x); // expected-warning{{pointer is missing a nullability type specifier}}
     98 
     99 @interface A(OutsidePragmas1)
    100 + (instancetype)aWithInt:(int)value; // expected-warning{{pointer is missing a nullability type specifier}}
    101 @end
    102