diff options
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 12 | ||||
-rw-r--r-- | clang/test/SemaObjCXX/Inputs/nullability-consistency-1.h | 8 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index e9acd9db73d..46cc0b9ac1e 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -3600,7 +3600,17 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // inner pointers. complainAboutMissingNullability = CAMN_InnerPointers; - if (T->canHaveNullability() && !T->getNullability(S.Context)) { + auto isDependentNonPointerType = [](QualType T) -> bool { + // Note: This is intended to be the same check as Type::canHaveNullability + // except with all of the ambiguous cases being treated as 'false' rather + // than 'true'. + return T->isDependentType() && !T->isAnyPointerType() && + !T->isBlockPointerType() && !T->isMemberPointerType(); + }; + + if (T->canHaveNullability() && !T->getNullability(S.Context) && + !isDependentNonPointerType(T)) { + // Note that we allow but don't require nullability on dependent types. ++NumPointersRemaining; } diff --git a/clang/test/SemaObjCXX/Inputs/nullability-consistency-1.h b/clang/test/SemaObjCXX/Inputs/nullability-consistency-1.h index 6ab48fe0cd8..a99f091e0f2 100644 --- a/clang/test/SemaObjCXX/Inputs/nullability-consistency-1.h +++ b/clang/test/SemaObjCXX/Inputs/nullability-consistency-1.h @@ -13,5 +13,13 @@ class X { int X:: *memptr; // expected-warning{{member pointer is missing a nullability type specifier}} }; +template <typename T> +struct Typedefs { + typedef T *Base; // no-warning + typedef Base *type; // expected-warning{{pointer is missing a nullability type specifier}} +}; + +Typedefs<int> xx; +Typedefs<void *> yy; |