diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp index 9e146ed3a642..f7aace625a92 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -291,8 +291,10 @@ bool Sema::isAcceptableNestedNameSpecifier(const NamedDecl *SD, if (!SD) return false; + SD = SD->getUnderlyingDecl(); + // Namespace and namespace aliases are fine. - if (isa<NamespaceDecl>(SD) || isa<NamespaceAliasDecl>(SD)) + if (isa<NamespaceDecl>(SD)) return true; if (!isa<TypeDecl>(SD)) @@ -396,10 +398,7 @@ bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, } Found.suppressDiagnostics(); - if (NamedDecl *ND = Found.getAsSingle<NamedDecl>()) - return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND); - - return false; + return Found.getAsSingle<NamespaceDecl>(); } namespace { @@ -533,6 +532,9 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, LookupName(Found, S); } + if (Found.isAmbiguous()) + return true; + // If we performed lookup into a dependent context and did not find anything, // that's fine: just build a dependent nested-name-specifier. if (Found.empty() && isDependent && @@ -551,8 +553,6 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, return false; } - // FIXME: Deal with ambiguities cleanly. - if (Found.empty() && !ErrorRecoveryLookup) { // If identifier is not found as class-name-or-namespace-name, but is found // as other entity, don't look for typos. @@ -562,6 +562,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, else if (S && !isDependent) LookupName(R, S); if (!R.empty()) { + // Don't diagnose problems with this speculative lookup. + R.suppressDiagnostics(); // The identifier is found in ordinary lookup. If correction to colon is // allowed, suggest replacement to ':'. if (IsCorrectedToColon) { @@ -604,7 +606,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, diagnoseTypo(Corrected, PDiag(diag::err_undeclared_var_use_suggest) << Name); - if (NamedDecl *ND = Corrected.getCorrectionDecl()) + if (NamedDecl *ND = Corrected.getFoundDecl()) Found.addDecl(ND); Found.setLookupName(Corrected.getCorrection()); } else { @@ -612,7 +614,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, } } - NamedDecl *SD = Found.getAsSingle<NamedDecl>(); + NamedDecl *SD = + Found.isSingleResult() ? Found.getRepresentativeDecl() : nullptr; bool IsExtension = false; bool AcceptSpec = isAcceptableNestedNameSpecifier(SD, &IsExtension); if (!AcceptSpec && IsExtension) { @@ -684,7 +687,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, return false; } - QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD)); + QualType T = + Context.getTypeDeclType(cast<TypeDecl>(SD->getUnderlyingDecl())); TypeLocBuilder TLB; if (isa<InjectedClassNameType>(T)) { InjectedClassNameTypeLoc InjectedTL |