diff options
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 634e699056e..b4d6175622d 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -7198,7 +7198,8 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, // as if by qualified name lookup. LookupResult R(*this, II, IdentLoc, LookupOrdinaryName, ForRedeclaration); LookupQualifiedName(R, CurContext->getRedeclContext()); - NamedDecl *PrevDecl = R.getAsSingle<NamedDecl>(); + NamedDecl *PrevDecl = + R.isSingleResult() ? R.getRepresentativeDecl() : nullptr; PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl); if (PrevNS) { @@ -7579,9 +7580,9 @@ Decl *Sema::ActOnUsingDirective(Scope *S, } if (!R.empty()) { - NamedDecl *Named = R.getFoundDecl(); - assert((isa<NamespaceDecl>(Named) || isa<NamespaceAliasDecl>(Named)) - && "expected namespace decl"); + NamedDecl *Named = R.getRepresentativeDecl(); + NamespaceDecl *NS = R.getAsSingle<NamespaceDecl>(); + assert(NS && "expected namespace decl"); // The use of a nested name specifier may trigger deprecation warnings. DiagnoseUseOfDecl(Named, IdentLoc); @@ -7598,7 +7599,6 @@ Decl *Sema::ActOnUsingDirective(Scope *S, // Find enclosing context containing both using-directive and // nominated namespace. - NamespaceDecl *NS = getNamespaceDecl(Named); DeclContext *CommonAncestor = cast<DeclContext>(NS); while (CommonAncestor && !CommonAncestor->Encloses(CurContext)) CommonAncestor = CommonAncestor->getParent(); @@ -8669,7 +8669,7 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope *S, SourceLocation NamespaceLoc, } } assert(!R.isAmbiguous() && !R.empty()); - NamedDecl *ND = R.getFoundDecl(); + NamedDecl *ND = R.getRepresentativeDecl(); // Check if we have a previous declaration with the same name. LookupResult PrevR(*this, Alias, AliasLoc, LookupOrdinaryName, @@ -8689,7 +8689,8 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope *S, SourceLocation NamespaceLoc, // Find the previous declaration and check that we can redeclare it. NamespaceAliasDecl *Prev = nullptr; if (NamedDecl *PrevDecl = PrevR.getAsSingle<NamedDecl>()) { - if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(PrevDecl)) { + if (NamespaceAliasDecl *AD = + dyn_cast<NamespaceAliasDecl>(PrevR.getRepresentativeDecl())) { // We already have an alias with the same name that points to the same // namespace; check that it matches. if (AD->getNamespace()->Equals(getNamespaceDecl(ND))) { @@ -8697,7 +8698,7 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope *S, SourceLocation NamespaceLoc, } else if (isVisible(PrevDecl)) { Diag(AliasLoc, diag::err_redefinition_different_namespace_alias) << Alias; - Diag(PrevDecl->getLocation(), diag::note_previous_namespace_alias) + Diag(AD->getLocation(), diag::note_previous_namespace_alias) << AD->getNamespace(); return nullptr; } |