When typo-correction an Objective-C superclass name, don't

typo-correct to ourselves.

llvm-svn: 145583
This commit is contained in:
Douglas Gregor 2011-12-01 15:37:53 +00:00
parent b8e6cee9ca
commit 11bb308457
2 changed files with 12 additions and 5 deletions

View File

@ -417,10 +417,15 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope,
NULL, NULL, false, CTC_NoKeywords);
if ((PrevDecl = Corrected.getCorrectionDeclAs<ObjCInterfaceDecl>())) {
Diag(SuperLoc, diag::err_undef_superclass_suggest)
<< SuperName << ClassName << PrevDecl->getDeclName();
Diag(PrevDecl->getLocation(), diag::note_previous_decl)
<< PrevDecl->getDeclName();
if (PrevDecl == IDecl) {
// Don't correct to the class we're defining.
PrevDecl = 0;
} else {
Diag(SuperLoc, diag::err_undef_superclass_suggest)
<< SuperName << ClassName << PrevDecl->getDeclName();
Diag(PrevDecl->getLocation(), diag::note_previous_decl)
<< PrevDecl->getDeclName();
}
}
}

View File

@ -30,4 +30,6 @@ typedef NSObject TD_NSObject;
@interface XCElementUnit : TD_NSObject {}
@end
// Make sure we don't typo-correct to ourselves.
@interface SomeClassSub : SomeClassSup // expected-error{{cannot find interface declaration for 'SomeClassSup', superclass of 'SomeClassSub'}}
@end