When declaring a namespace alias, ignore previous declarations that

aren't in scope. Fixes PR7014.

llvm-svn: 102915
This commit is contained in:
Douglas Gregor 2010-05-03 15:37:31 +00:00
parent 95c70ec678
commit 5cf8d67bc9
2 changed files with 17 additions and 3 deletions

View File

@ -4004,9 +4004,13 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
LookupParsedName(R, S, &SS);
// Check if we have a previous declaration with the same name.
if (NamedDecl *PrevDecl
= LookupSingleName(S, Alias, AliasLoc, LookupOrdinaryName,
ForRedeclaration)) {
NamedDecl *PrevDecl
= LookupSingleName(S, Alias, AliasLoc, LookupOrdinaryName,
ForRedeclaration);
if (PrevDecl && !isDeclInScope(PrevDecl, CurContext, S))
PrevDecl = 0;
if (PrevDecl) {
if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(PrevDecl)) {
// We already have an alias with the same name that points to the same
// namespace, so don't create a new one.

View File

@ -91,3 +91,13 @@ namespace A = N;
A::X nx;
namespace PR7014 {
namespace X
{
namespace Y {}
}
using namespace X;
namespace Y = X::Y;
}