]> granicus.if.org Git - clang/commitdiff
Don't accept a typo correction if the corrected identifier is the same as the
authorKaelyn Uhrain <rikka@google.com>
Thu, 18 Aug 2011 21:57:36 +0000 (21:57 +0000)
committerKaelyn Uhrain <rikka@google.com>
Thu, 18 Aug 2011 21:57:36 +0000 (21:57 +0000)
uncorrected identifier. Fixes a problem pointed out by Eli.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137987 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/function-redecl.cpp

index 898fca4203d1031e199ac059f8f099ff2452c6a8..106363f6d73d58e00d807b12e1ea0d0040f8cefc 100644 (file)
@@ -4235,7 +4235,8 @@ static void DiagnoseInvalidRedeclaration(Sema &S, FunctionDecl *NewFD,
     }
   // If the qualified name lookup yielded nothing, try typo correction
   } else if ((Correction = S.CorrectTypo(Prev.getLookupNameInfo(),
-                                         Prev.getLookupKind(), 0, 0, DC))) {
+                                         Prev.getLookupKind(), 0, 0, DC)) &&
+             Correction.getCorrection() != Name) {
     DiagMsg = isFriendDecl ? diag::err_no_matching_local_friend_suggest
                            : diag::err_member_def_does_not_match_suggest;
     for (TypoCorrection::decl_iterator CDecl = Correction.begin(),
index 8c734945f25320ddc6c782b871b3e9b39a44bef1..2ea407cdf5e517da0c8a95585ec90d013b04eebc 100644 (file)
@@ -50,3 +50,7 @@ class B {
 
 void B::Notypocorrection(int) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}}
 }
+
+struct X { int f(); };
+struct Y : public X {};
+int Y::f() { return 3; } // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Y'}}