Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -3894,8 +3894,22 @@ attr->setUsedAsTypeAttr(); } } + + auto isVaList = [&S](QualType T) -> bool { + auto *typedefTy = T->getAs(); + if (!typedefTy) + return false; + TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl(); + do { + if (typedefTy->getDecl() == vaListTypedef) + return true; + typedefTy = typedefTy->desugar()->getAs(); + } while (typedefTy); + return false; + }; + if (complainAboutMissingNullability == CAMN_Yes && - T->isArrayType() && !T->getNullability(S.Context) && + T->isArrayType() && !T->getNullability(S.Context) && !isVaList(T) && D.isPrototypeContext() && !hasOuterPointerLikeChunk(D, D.getNumTypeObjects())) { checkNullabilityConsistency(S, SimplePointerKind::Array, Index: test/SemaObjCXX/Inputs/nullability-consistency-arrays.h =================================================================== --- test/SemaObjCXX/Inputs/nullability-consistency-arrays.h +++ test/SemaObjCXX/Inputs/nullability-consistency-arrays.h @@ -1,3 +1,5 @@ +#include + void firstThingInTheFileThatNeedsNullabilityIsAnArray(int ints[]); #if ARRAYS_CHECKED // expected-warning@-2 {{array parameter is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)}} @@ -33,6 +35,26 @@ 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 +struct pointer_like_or { typedef F type; }; +template +struct pointer_like_or { typedef T *type; }; +template +struct pointer_like_or { typedef T * const type; }; +template +struct pointer_like_or { typedef T type[]; }; +template +struct pointer_like_or { typedef T type[size]; }; + +void testVAListWithNullability( + pointer_like_or::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 (_Nonnull, _Nullable, or _Null_unspecified)}}