[SemaObjC] Fix a crash on invalid when 'auto' is used in a @property

rdar://48506879
This commit is contained in:
Erik Pilkington 2020-06-24 12:11:39 -04:00
parent 4fb2116ee7
commit 69d2fa9ed1
2 changed files with 25 additions and 11 deletions

View File

@ -3301,6 +3301,9 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
D.isFunctionDeclarator()) D.isFunctionDeclarator())
break; break;
bool Cxx = SemaRef.getLangOpts().CPlusPlus; bool Cxx = SemaRef.getLangOpts().CPlusPlus;
if (isa<ObjCContainerDecl>(SemaRef.CurContext)) {
Error = 6; // Interface member.
} else {
switch (cast<TagDecl>(SemaRef.CurContext)->getTagKind()) { switch (cast<TagDecl>(SemaRef.CurContext)->getTagKind()) {
case TTK_Enum: llvm_unreachable("unhandled tag kind"); case TTK_Enum: llvm_unreachable("unhandled tag kind");
case TTK_Struct: Error = Cxx ? 1 : 2; /* Struct member */ break; case TTK_Struct: Error = Cxx ? 1 : 2; /* Struct member */ break;
@ -3308,6 +3311,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
case TTK_Class: Error = 5; /* Class member */ break; case TTK_Class: Error = 5; /* Class member */ break;
case TTK_Interface: Error = 6; /* Interface member */ break; case TTK_Interface: Error = 6; /* Interface member */ break;
} }
}
if (D.getDeclSpec().isFriendSpecified()) if (D.getDeclSpec().isFriendSpecified())
Error = 20; // Friend type Error = 20; // Friend type
break; break;
@ -7031,15 +7035,15 @@ static bool checkNullabilityTypeSpecifier(TypeProcessingState &state,
// attributes, require that the type be a single-level pointer. // attributes, require that the type be a single-level pointer.
if (isContextSensitive) { if (isContextSensitive) {
// Make sure that the pointee isn't itself a pointer type. // Make sure that the pointee isn't itself a pointer type.
const Type *pointeeType; const Type *pointeeType = nullptr;
if (desugared->isArrayType()) if (desugared->isArrayType())
pointeeType = desugared->getArrayElementTypeNoTypeQual(); pointeeType = desugared->getArrayElementTypeNoTypeQual();
else else if (desugared->isAnyPointerType())
pointeeType = desugared->getPointeeType().getTypePtr(); pointeeType = desugared->getPointeeType().getTypePtr();
if (pointeeType->isAnyPointerType() || if (pointeeType && (pointeeType->isAnyPointerType() ||
pointeeType->isObjCObjectPointerType() || pointeeType->isObjCObjectPointerType() ||
pointeeType->isMemberPointerType()) { pointeeType->isMemberPointerType())) {
S.Diag(nullabilityLoc, diag::err_nullability_cs_multilevel) S.Diag(nullabilityLoc, diag::err_nullability_cs_multilevel)
<< DiagNullabilityKind(nullability, true) << DiagNullabilityKind(nullability, true)
<< type; << type;

View File

@ -21,3 +21,13 @@ void foo(I *i)
{ {
i.helper; // expected-warning{{property access result unused - getters should not be used for side effects}} 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