diff options
-rw-r--r-- | lib/Frontend/FixItRewriter.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 8 | ||||
-rw-r--r-- | test/SemaObjC/undef-superclass-1.m | 3 |
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/Frontend/FixItRewriter.cpp b/lib/Frontend/FixItRewriter.cpp index 4fa2b3c51e..0b04cf2b44 100644 --- a/lib/Frontend/FixItRewriter.cpp +++ b/lib/Frontend/FixItRewriter.cpp @@ -115,6 +115,9 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel, if (!AcceptableLocation) return; + } else if (DiagLevel == Diagnostic::Note) { + // Don't apply fix-it modifications in notes. + return; } // Make sure that we can perform all of the modifications we diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index f627c23d76..e5526746d9 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -701,11 +701,17 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation( LookupResult R(*this, ClassName, ClassLoc, LookupOrdinaryName); if (CorrectTypo(R, TUScope, 0) && (IDecl = R.getAsSingle<ObjCInterfaceDecl>())) { - // Suggest the (potentially) correct interface name. However, don't + // Suggest the (potentially) correct interface name. However, put the + // fix-it hint itself in a separate note, since changing the name in + // the warning would make the fix-it change semantics.However, don't // provide a code-modification hint or use the typo name for recovery, // because this is just a warning. The program may actually be correct. Diag(ClassLoc, diag::warn_undef_interface_suggest) << ClassName << R.getLookupName(); + Diag(IDecl->getLocation(), diag::note_previous_decl) + << R.getLookupName() + << CodeModificationHint::CreateReplacement(ClassLoc, + R.getLookupName().getAsString()); IDecl = 0; } else { Diag(ClassLoc, diag::warn_undef_interface) << ClassName; diff --git a/test/SemaObjC/undef-superclass-1.m b/test/SemaObjC/undef-superclass-1.m index 56697e23c2..0c2594cc22 100644 --- a/test/SemaObjC/undef-superclass-1.m +++ b/test/SemaObjC/undef-superclass-1.m @@ -13,7 +13,8 @@ @interface INTF2 : INTF1 @end -@interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}} +@interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}} \ + // expected-note{{'INTF3' declared here}} @end @interface INTF1 // expected-error {{duplicate interface definition for class 'INTF1'}} |