When typo correction produces a result that is not of the kind we're

looking for, reset the name within the LookupResult structure in
addition to clearing out the results. Fixes PR7508.

llvm-svn: 107197
This commit is contained in:
Douglas Gregor
2010-06-29 19:27:42 +00:00
parent cccaad9584
commit c048c52734
5 changed files with 27 additions and 2 deletions

View File

@@ -458,8 +458,10 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
Diag(ND->getLocation(), diag::note_previous_decl)
<< ND->getDeclName();
} else
} else {
Found.clear();
Found.setLookupName(&II);
}
}
NamedDecl *SD = Found.getAsSingle<NamedDecl>();

View File

@@ -1139,6 +1139,7 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
return true;
R.clear();
R.setLookupName(MemberOrBase);
}
}
@@ -3516,6 +3517,9 @@ Sema::DeclPtrTy Sema::ActOnUsingDirective(Scope *S,
<< Corrected;
NamespcName = Corrected.getAsIdentifierInfo();
} else {
R.clear();
R.setLookupName(NamespcName);
}
}
}
@@ -4240,6 +4244,9 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
<< Corrected;
Ident = Corrected.getAsIdentifierInfo();
} else {
R.clear();
R.setLookupName(Ident);
}
}

View File

@@ -2620,6 +2620,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
return false;
} else {
R.clear();
R.setLookupName(Name);
}
return false;
@@ -3080,6 +3081,9 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
IV->getNameAsString());
Diag(IV->getLocation(), diag::note_previous_decl)
<< IV->getDeclName();
} else {
Res.clear();
Res.setLookupName(Member);
}
}

View File

@@ -258,7 +258,7 @@ void Sema::LookupTemplateName(LookupResult &Found,
// If we did not find any names, attempt to correct any typos.
DeclarationName Name = Found.getLookupName();
if (DeclarationName Corrected = CorrectTypo(Found, S, &SS, LookupCtx,
false, CTC_CXXCasts)) {
false, CTC_CXXCasts)) {
FilterAcceptableTemplateNames(Context, Found);
if (!Found.empty()) {
if (LookupCtx)
@@ -277,6 +277,7 @@ void Sema::LookupTemplateName(LookupResult &Found,
}
} else {
Found.clear();
Found.setLookupName(Name);
}
}

View File

@@ -90,3 +90,14 @@ namespace test5 {
x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
}
}
namespace PR7508 {
struct A {
struct CleanupScope {};
void PopCleanupBlock();
};
void foo(A &a) {
a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'}}
}
}