summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ed5724b88fb..f5bb3511f22 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -7301,9 +7301,10 @@ void Sema::HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow) {
namespace {
class UsingValidatorCCC : public CorrectionCandidateCallback {
public:
- UsingValidatorCCC(bool HasTypenameKeyword, bool IsInstantiation)
+ UsingValidatorCCC(bool HasTypenameKeyword, bool IsInstantiation,
+ bool RequireMember)
: HasTypenameKeyword(HasTypenameKeyword),
- IsInstantiation(IsInstantiation) {}
+ IsInstantiation(IsInstantiation), RequireMember(RequireMember) {}
bool ValidateCandidate(const TypoCorrection &Candidate) LLVM_OVERRIDE {
NamedDecl *ND = Candidate.getCorrectionDecl();
@@ -7312,6 +7313,10 @@ public:
if (!ND || isa<NamespaceDecl>(ND))
return false;
+ if (RequireMember && !isa<FieldDecl>(ND) && !isa<CXXMethodDecl>(ND) &&
+ !isa<TypeDecl>(ND))
+ return false;
+
// Completely unqualified names are invalid for a 'using' declaration.
if (Candidate.WillReplaceSpecifier() && !Candidate.getCorrectionSpecifier())
return false;
@@ -7325,6 +7330,7 @@ public:
private:
bool HasTypenameKeyword;
bool IsInstantiation;
+ bool RequireMember;
};
} // end anonymous namespace
@@ -7440,7 +7446,8 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
// Try to correct typos if possible.
if (R.empty()) {
- UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation);
+ UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation,
+ CurContext->isRecord());
if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(),
R.getLookupKind(), S, &SS, CCC)){
// We reject any correction for which ND would be NULL.
OpenPOWER on IntegriCloud