1 // RUN: %clang_cc1 -fsyntax-only -Wnonnull -Wnullability %s -verify
3 #if __has_feature(nullability)
5 # error nullability feature should be defined
9 int * _Nullable
foo(int * _Nonnull x
);
11 int *_Nonnull
ret_nonnull(void);
17 int * _Nullable
foo1(int * _Nonnull x
); // expected-note {{previous declaration is here}}
19 int *foo1(int * _Nullable x
) { // expected-warning {{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
23 int * _Nullable
foo2(int * _Nonnull x
);
25 int *foo2(int * _Nonnull x
) {
29 int * _Nullable
foo3(int * _Nullable x
); // expected-note {{previous declaration is here}}
31 int *foo3(int * _Nonnull x
) { // expected-warning {{nullability specifier '_Nonnull' conflicts with existing specifier '_Nullable'}}
35 int * ret_nonnull(void) {
36 return 0; // expected-warning {{null returned from function that requires a non-null return value}}
39 int foo4(int * _Nonnull x
, int * y
) {
43 #define SAFE_CALL(X) if (X) foo(X)
45 foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
46 (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
47 SAFE_CALL(0); // expect no diagnostic for unreachable code.
49 0, // expected-warning {{null passed to a callee that requires a non-null argument}}