Don't accept a typo correction if the corrected identifier is the same as the

uncorrected identifier. Fixes a problem pointed out by Eli.

llvm-svn: 137987
This commit is contained in:
Kaelyn Uhrain 2011-08-18 21:57:36 +00:00
parent 90103ccc05
commit 40aa7c91b6
2 changed files with 6 additions and 1 deletions

View 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(),

View 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'}}