diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -4748,8 +4748,13 @@ } // Weak properties are inferred to be nullable. - if (state.getDeclarator().isObjCWeakProperty() && inAssumeNonNullRegion) { - inferNullability = NullabilityKind::Nullable; + if (state.getDeclarator().isObjCWeakProperty()) { + // Weak properties cannot be nonnull, and should not complain about + // missing nullable attributes during completeness checks. + complainAboutMissingNullability = CAMN_No; + if (inAssumeNonNullRegion) { + inferNullability = NullabilityKind::Nullable; + } break; } diff --git a/clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h b/clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h --- a/clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h +++ b/clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h @@ -19,13 +19,9 @@ @property (retain,nullable) SomeClass *property2; - (nullable SomeClass *)method1; - (void)method2:(nonnull SomeClass *)param; -@property (readonly, weak) SomeClass *property3; // expected-warning{{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}} +@property (readonly, weak) SomeClass *property3; @end @interface SomeClass () -@property (readonly, weak) SomeClass *property4; // expected-warning{{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}} +@property (readonly, weak) SomeClass *property4; @end