2015-06-20 02:25:57 +08:00
// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs %s -verify
#include "nullability-pragmas-1.h"
#include "nullability-pragmas-2.h"
#if !__has_feature(assume_nonnull)
# error assume_nonnull feature is not set
#endif
2015-06-25 06:02:08 +08:00
void test_pragmas_1(A * _Nonnull a, AA * _Nonnull aa) {
2015-06-20 02:25:57 +08:00
f1(0); // okay: no nullability annotations
f2(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f3(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f4(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f5(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f6(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f7(0); // okay
f8(0); // okay
f9(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f10(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
f11(0); // okay
f12(0); // okay
[a method1:0]; // expected-warning{{null passed to a callee that requires a non-null argument}}
f17(a); // expected-error{{no matching function for call to 'f17'}}
2015-06-25 06:02:08 +08:00
[a method3: a]; // expected-error{{cannot initialize a parameter of type 'NSError * _Nullable * _Nullable' with an lvalue of type 'A * _Nonnull'}}
[a method4: a]; // expected-error{{cannot initialize a parameter of type 'NSErrorPtr _Nullable * _Nullable' (aka 'NSError **') with an lvalue of type 'A * _Nonnull'}}
2015-06-20 02:25:57 +08:00
float *ptr;
2015-06-25 06:02:08 +08:00
ptr = f13(); // expected-error{{assigning to 'float *' from incompatible type 'int_ptr _Nonnull' (aka 'int *')}}
ptr = f14(); // expected-error{{assigning to 'float *' from incompatible type 'A * _Nonnull'}}
ptr = [a method1:a]; // expected-error{{assigning to 'float *' from incompatible type 'A * _Nonnull'}}
ptr = a.aProp; // expected-error{{assigning to 'float *' from incompatible type 'A * _Nonnull'}}
ptr = global_int_ptr; // expected-error{{assigning to 'float *' from incompatible type 'int * _Nonnull'}}
ptr = f15(); // expected-error{{assigning to 'float *' from incompatible type 'int * _Null_unspecified'}}
ptr = f16(); // expected-error{{assigning to 'float *' from incompatible type 'A * _Null_unspecified'}}
ptr = [a method2]; // expected-error{{assigning to 'float *' from incompatible type 'A * _Null_unspecified'}}
2015-06-20 02:25:57 +08:00
ptr = aa->ivar1; // expected-error{{from incompatible type 'id'}}
2015-06-25 06:02:08 +08:00
ptr = aa->ivar2; // expected-error{{from incompatible type 'id _Nonnull'}}
2015-06-20 02:25:57 +08:00
}