diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 46fa8bc0608b..81a0c4a2a9c2 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -3301,12 +3301,16 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, D.isFunctionDeclarator()) break; bool Cxx = SemaRef.getLangOpts().CPlusPlus; - switch (cast(SemaRef.CurContext)->getTagKind()) { - case TTK_Enum: llvm_unreachable("unhandled tag kind"); - case TTK_Struct: Error = Cxx ? 1 : 2; /* Struct member */ break; - case TTK_Union: Error = Cxx ? 3 : 4; /* Union member */ break; - case TTK_Class: Error = 5; /* Class member */ break; - case TTK_Interface: Error = 6; /* Interface member */ break; + if (isa(SemaRef.CurContext)) { + Error = 6; // Interface member. + } else { + switch (cast(SemaRef.CurContext)->getTagKind()) { + case TTK_Enum: llvm_unreachable("unhandled tag kind"); + case TTK_Struct: Error = Cxx ? 1 : 2; /* Struct member */ break; + case TTK_Union: Error = Cxx ? 3 : 4; /* Union member */ break; + case TTK_Class: Error = 5; /* Class member */ break; + case TTK_Interface: Error = 6; /* Interface member */ break; + } } if (D.getDeclSpec().isFriendSpecified()) Error = 20; // Friend type @@ -7031,15 +7035,15 @@ static bool checkNullabilityTypeSpecifier(TypeProcessingState &state, // attributes, require that the type be a single-level pointer. if (isContextSensitive) { // Make sure that the pointee isn't itself a pointer type. - const Type *pointeeType; + const Type *pointeeType = nullptr; if (desugared->isArrayType()) pointeeType = desugared->getArrayElementTypeNoTypeQual(); - else + else if (desugared->isAnyPointerType()) pointeeType = desugared->getPointeeType().getTypePtr(); - if (pointeeType->isAnyPointerType() || - pointeeType->isObjCObjectPointerType() || - pointeeType->isMemberPointerType()) { + if (pointeeType && (pointeeType->isAnyPointerType() || + pointeeType->isObjCObjectPointerType() || + pointeeType->isMemberPointerType())) { S.Diag(nullabilityLoc, diag::err_nullability_cs_multilevel) << DiagNullabilityKind(nullability, true) << type; diff --git a/clang/test/SemaObjCXX/property-invalid-type.mm b/clang/test/SemaObjCXX/property-invalid-type.mm index 9122426f4c30..35a5f3a5a525 100644 --- a/clang/test/SemaObjCXX/property-invalid-type.mm +++ b/clang/test/SemaObjCXX/property-invalid-type.mm @@ -21,3 +21,13 @@ void foo(I *i) { i.helper; // expected-warning{{property access result unused - getters should not be used for side effects}} } + +@interface J +@property (nonnull) auto a; // expected-error {{'auto' not allowed in interface member}} +@property auto b; // expected-error {{'auto' not allowed in interface member}} +@property (nullable) auto c; // expected-error {{'auto' not allowed in interface member}} +@end + +@interface J (Cat) +@property (nonnull) auto catprop; // expected-error {{'auto' not allowed in interface member}} +@end