@@ -3827,6 +3827,23 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
3827
3827
}
3828
3828
}
3829
3829
3830
+ // Local function that returns true if its argument looks like a va_list.
3831
+ auto isVaList = [&S](QualType T) -> bool {
3832
+ auto *typedefTy = T->getAs <TypedefType>();
3833
+ if (!typedefTy)
3834
+ return false ;
3835
+ TypedefDecl *vaListTypedef = S.Context .getBuiltinVaListDecl ();
3836
+ do {
3837
+ if (typedefTy->getDecl () == vaListTypedef)
3838
+ return true ;
3839
+ if (auto *name = typedefTy->getDecl ()->getIdentifier ())
3840
+ if (name->isStr (" va_list" ))
3841
+ return true ;
3842
+ typedefTy = typedefTy->desugar ()->getAs <TypedefType>();
3843
+ } while (typedefTy);
3844
+ return false ;
3845
+ };
3846
+
3830
3847
// Local function that checks the nullability for a given pointer declarator.
3831
3848
// Returns true if _Nonnull was inferred.
3832
3849
auto inferPointerNullability = [&](SimplePointerKind pointerKind,
@@ -3905,37 +3922,27 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
3905
3922
// nullability and perform consistency checking.
3906
3923
if (S.ActiveTemplateInstantiations .empty ()) {
3907
3924
if (T->canHaveNullability () && !T->getNullability (S.Context )) {
3908
- SimplePointerKind pointerKind = SimplePointerKind::Pointer;
3909
- if (T->isBlockPointerType ())
3910
- pointerKind = SimplePointerKind::BlockPointer;
3911
- else if (T->isMemberPointerType ())
3912
- pointerKind = SimplePointerKind::MemberPointer;
3913
-
3914
- if (auto *attr = inferPointerNullability (
3915
- pointerKind, D.getDeclSpec ().getTypeSpecTypeLoc (),
3916
- D.getMutableDeclSpec ().getAttributes ().getListRef ())) {
3917
- T = Context.getAttributedType (
3918
- AttributedType::getNullabilityAttrKind (*inferNullability), T, T);
3919
- attr->setUsedAsTypeAttr ();
3925
+ if (isVaList (T)) {
3926
+ // Record that we've seen a pointer, but do nothing else.
3927
+ if (NumPointersRemaining > 0 )
3928
+ --NumPointersRemaining;
3929
+ } else {
3930
+ SimplePointerKind pointerKind = SimplePointerKind::Pointer;
3931
+ if (T->isBlockPointerType ())
3932
+ pointerKind = SimplePointerKind::BlockPointer;
3933
+ else if (T->isMemberPointerType ())
3934
+ pointerKind = SimplePointerKind::MemberPointer;
3935
+
3936
+ if (auto *attr = inferPointerNullability (
3937
+ pointerKind, D.getDeclSpec ().getTypeSpecTypeLoc (),
3938
+ D.getMutableDeclSpec ().getAttributes ().getListRef ())) {
3939
+ T = Context.getAttributedType (
3940
+ AttributedType::getNullabilityAttrKind (*inferNullability),T,T);
3941
+ attr->setUsedAsTypeAttr ();
3942
+ }
3920
3943
}
3921
3944
}
3922
3945
3923
- auto isVaList = [&S](QualType T) -> bool {
3924
- auto *typedefTy = T->getAs <TypedefType>();
3925
- if (!typedefTy)
3926
- return false ;
3927
- TypedefDecl *vaListTypedef = S.Context .getBuiltinVaListDecl ();
3928
- do {
3929
- if (typedefTy->getDecl () == vaListTypedef)
3930
- return true ;
3931
- if (auto *name = typedefTy->getDecl ()->getIdentifier ())
3932
- if (name->isStr (" va_list" ))
3933
- return true ;
3934
- typedefTy = typedefTy->desugar ()->getAs <TypedefType>();
3935
- } while (typedefTy);
3936
- return false ;
3937
- };
3938
-
3939
3946
if (complainAboutMissingNullability == CAMN_Yes &&
3940
3947
T->isArrayType () && !T->getNullability (S.Context ) && !isVaList (T) &&
3941
3948
D.isPrototypeContext () &&
0 commit comments