aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDeclCXX.cpp10
-rw-r--r--test/SemaCXX/namespace-alias.cpp10
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 1ca7a728f0..0db0d9e389 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -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.
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 3ea1ccfd9f..1c3da3c656 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -91,3 +91,13 @@ namespace A = N;
A::X nx;
+namespace PR7014 {
+ namespace X
+ {
+ namespace Y {}
+ }
+
+ using namespace X;
+
+ namespace Y = X::Y;
+}