xref: /llvm-project/clang/test/Parser/nullability.c (revision 303e2f1eac90bf1be2eb9255411107b5ffb8a475)
1261a89b0SDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -std=c99 -Wno-nullability-declspec -pedantic %s -verify
2261a89b0SDouglas Gregor 
3aea7afdcSDouglas Gregor _Nonnull int *ptr; // expected-warning{{type nullability specifier '_Nonnull' is a Clang extension}}
4261a89b0SDouglas Gregor 
5261a89b0SDouglas Gregor #pragma clang diagnostic push
6261a89b0SDouglas Gregor #pragma clang diagnostic ignored "-Wnullability-extension"
7aea7afdcSDouglas Gregor _Nonnull int *ptr2; // no-warning
8261a89b0SDouglas Gregor #pragma clang diagnostic pop
9261a89b0SDouglas Gregor 
1055c4ef3eSDouglas Gregor #if !__has_feature(nullability)
1155c4ef3eSDouglas Gregor #  error Nullability should always be supported
12261a89b0SDouglas Gregor #endif
13261a89b0SDouglas Gregor 
14*303e2f1eSJordan Rose #if !__has_feature(nullability_on_arrays)
15*303e2f1eSJordan Rose #  error Nullability on array parameters should always be supported
16*303e2f1eSJordan Rose #endif
17*303e2f1eSJordan Rose 
18261a89b0SDouglas Gregor #if !__has_extension(nullability)
19261a89b0SDouglas Gregor #  error Nullability should always be supported as an extension
20261a89b0SDouglas Gregor #endif
21*303e2f1eSJordan Rose 
22*303e2f1eSJordan Rose #if !__has_extension(nullability_on_arrays)
23*303e2f1eSJordan Rose #  error Nullability on array parameters should always be supported as an extension
24*303e2f1eSJordan Rose #endif
25