3 void firstThingInTheFileThatNeedsNullabilityIsAnArray(int ints
[]);
5 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
6 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
7 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
10 int *secondThingInTheFileThatNeedsNullabilityIsAPointer
;
12 // expected-warning@-2 {{pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)}}
13 // expected-note@-3 {{insert '_Nullable' if the pointer may be null}}
14 // expected-note@-4 {{insert '_Nonnull' if the pointer should never be null}}
17 int *_Nonnull triggerConsistencyWarnings
;
22 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
23 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
24 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
26 void *ptrs
[], // expected-warning {{pointer is missing a nullability type specifier}}
27 // expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
28 // expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
30 // expected-warning@-4 {{array parameter is missing a nullability type specifier}}
31 // expected-note@-5 {{insert '_Nullable' if the array parameter may be null}}
32 // expected-note@-6 {{insert '_Nonnull' if the array parameter should never be null}}
34 void **nestedPtrs
[]); // expected-warning 2 {{pointer is missing a nullability type specifier}}
35 // expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
36 // expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
38 // expected-warning@-4 {{array parameter is missing a nullability type specifier}}
39 // expected-note@-5 {{insert '_Nullable' if the array parameter may be null}}
40 // expected-note@-6 {{insert '_Nonnull' if the array parameter should never be null}}
45 void *ptrs
[_Nonnull
], // expected-warning {{pointer is missing a nullability type specifier}}
46 // expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
47 // expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
48 void **nestedPtrs
[_Nonnull
]); // expected-warning 2 {{pointer is missing a nullability type specifier}}
49 // expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
50 // expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
53 void * _Nullable ptrs
[_Nonnull
],
54 void * _Nullable
* _Nullable nestedPtrs
[_Nonnull
]);
56 void testVAList(va_list ok
); // no warning
59 // Carefully construct a test case such that if a platform's va_list is an array
60 // or pointer type, it gets tested, but otherwise it does not.
61 template<class T
, class F
>
62 struct pointer_like_or
{ typedef F type
; };
63 template<class T
, class F
>
64 struct pointer_like_or
<T
*, F
> { typedef T
*type
; };
65 template<class T
, class F
>
66 struct pointer_like_or
<T
* const, F
> { typedef T
* const type
; };
67 template<class T
, class F
>
68 struct pointer_like_or
<T
[], F
> { typedef T type
[]; };
69 template<class T
, class F
, unsigned size
>
70 struct pointer_like_or
<T
[size
], F
> { typedef T type
[size
]; };
72 void testVAListWithNullability(
73 pointer_like_or
<va_list, void*>::type _Nonnull x
); // no errors
76 void nestedArrays(int x
[5][1]) {}
78 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
79 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
80 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
82 void nestedArraysOK(int x
[_Nonnull
5][1]) {}
85 void staticOK(int x
[static 5][1]){}
88 int globalArraysDoNotNeedNullability
[5];
95 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
96 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
97 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
103 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
104 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
105 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
107 INTS y2
[_Nonnull
2]);
110 #pragma clang assume_nonnull begin
111 void testAssumeNonnull(
114 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
115 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
116 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
120 // expected-warning@-2 {{array parameter is missing a nullability type specifier}}
121 // expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
122 // expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
124 void **nestedPtrs
[]); // expected-warning 2 {{pointer is missing a nullability type specifier}}
125 // expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
126 // expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
128 // expected-warning@-4 {{array parameter is missing a nullability type specifier}}
129 // expected-note@-5 {{insert '_Nullable' if the array parameter may be null}}
130 // expected-note@-6 {{insert '_Nonnull' if the array parameter should never be null}}
133 void testAssumeNonnullAllOK(
135 void * _Nullable ptrs
[_Nonnull
],
136 void * _Nullable
* _Nullable nestedPtrs
[_Nonnull
]);
137 void testAssumeNonnullAllOK2(
139 void * ptrs
[_Nonnull
], // backwards-compatibility
140 void * _Nullable
* _Nullable nestedPtrs
[_Nonnull
]);
141 #pragma clang assume_nonnull end