Files
TheRock/compiler/amd-llvm/clang/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

142 lines
6.0 KiB
C++

#include <stdarg.h>
void firstThingInTheFileThatNeedsNullabilityIsAnArray(int ints[]);
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
int *secondThingInTheFileThatNeedsNullabilityIsAPointer;
#if !ARRAYS_CHECKED
// expected-warning@-2 {{pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)}}
// expected-note@-3 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-4 {{insert '_Nonnull' if the pointer should never be null}}
#endif
int *_Nonnull triggerConsistencyWarnings;
void test(
int ints[],
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void *ptrs[], // expected-warning {{pointer is missing a nullability type specifier}}
// expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
#if ARRAYS_CHECKED
// expected-warning@-4 {{array parameter is missing a nullability type specifier}}
// expected-note@-5 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-6 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void **nestedPtrs[]); // expected-warning 2 {{pointer is missing a nullability type specifier}}
// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
#if ARRAYS_CHECKED
// expected-warning@-4 {{array parameter is missing a nullability type specifier}}
// expected-note@-5 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-6 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void testArraysOK(
int ints[_Nonnull],
void *ptrs[_Nonnull], // expected-warning {{pointer is missing a nullability type specifier}}
// expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
void **nestedPtrs[_Nonnull]); // expected-warning 2 {{pointer is missing a nullability type specifier}}
// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
void testAllOK(
int ints[_Nonnull],
void * _Nullable ptrs[_Nonnull],
void * _Nullable * _Nullable nestedPtrs[_Nonnull]);
void testVAList(va_list ok); // no warning
#if __cplusplus
// Carefully construct a test case such that if a platform's va_list is an array
// or pointer type, it gets tested, but otherwise it does not.
template<class T, class F>
struct pointer_like_or { typedef F type; };
template<class T, class F>
struct pointer_like_or<T*, F> { typedef T *type; };
template<class T, class F>
struct pointer_like_or<T* const, F> { typedef T * const type; };
template<class T, class F>
struct pointer_like_or<T[], F> { typedef T type[]; };
template<class T, class F, unsigned size>
struct pointer_like_or<T[size], F> { typedef T type[size]; };
void testVAListWithNullability(
pointer_like_or<va_list, void*>::type _Nonnull x); // no errors
#endif
void nestedArrays(int x[5][1]) {}
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void nestedArraysOK(int x[_Nonnull 5][1]) {}
#if !__cplusplus
void staticOK(int x[static 5][1]){}
#endif
int globalArraysDoNotNeedNullability[5];
typedef int INTS[4];
void typedefTest(
INTS x,
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
INTS _Nonnull x2,
_Nonnull INTS x3,
INTS y[2],
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
INTS y2[_Nonnull 2]);
#pragma clang assume_nonnull begin
void testAssumeNonnull(
int ints[],
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void *ptrs[],
#if ARRAYS_CHECKED
// expected-warning@-2 {{array parameter is missing a nullability type specifier}}
// expected-note@-3 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-4 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void **nestedPtrs[]); // expected-warning 2 {{pointer is missing a nullability type specifier}}
// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
#if ARRAYS_CHECKED
// expected-warning@-4 {{array parameter is missing a nullability type specifier}}
// expected-note@-5 {{insert '_Nullable' if the array parameter may be null}}
// expected-note@-6 {{insert '_Nonnull' if the array parameter should never be null}}
#endif
void testAssumeNonnullAllOK(
int ints[_Nonnull],
void * _Nullable ptrs[_Nonnull],
void * _Nullable * _Nullable nestedPtrs[_Nonnull]);
void testAssumeNonnullAllOK2(
int ints[_Nonnull],
void * ptrs[_Nonnull], // backwards-compatibility
void * _Nullable * _Nullable nestedPtrs[_Nonnull]);
#pragma clang assume_nonnull end