aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-01 15:37:53 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-01 15:37:53 +0000
commita38c4730fb016abc20a5479540b65ff3992095ab (patch)
tree7b4c35d281bf8cc74ef83be344394a2ad10698d7
parent50118da99d3c04eb14747cfdc44a9e1d56432aea (diff)
When typo-correction an Objective-C superclass name, don't
typo-correct to ourselves. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145583 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclObjC.cpp13
-rw-r--r--test/SemaObjC/class-def-test-1.m4
2 files changed, 12 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 667a12fea4..49fcfbf2f3 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -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();
+ }
}
}
diff --git a/test/SemaObjC/class-def-test-1.m b/test/SemaObjC/class-def-test-1.m
index 95a259bd52..0d114b99fb 100644
--- a/test/SemaObjC/class-def-test-1.m
+++ b/test/SemaObjC/class-def-test-1.m
@@ -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