]> granicus.if.org Git - clang/commitdiff
When declaring a namespace alias, ignore previous declarations that
authorDouglas Gregor <dgregor@apple.com>
Mon, 3 May 2010 15:37:31 +0000 (15:37 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 3 May 2010 15:37:31 +0000 (15:37 +0000)
aren't in scope. Fixes PR7014.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102915 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/namespace-alias.cpp

index 1ca7a728f0a3d951b4190fce1cb80c8fde6eff54..0db0d9e38963c5ea3e21f2bb942a112cf4a16f52 100644 (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.
index 3ea1ccfd9f70a6a3db4ff3e24e82486ff5d1703a..1c3da3c656a61afa25a0ac5b4e8cde6a2e127e96 100644 (file)
@@ -91,3 +91,13 @@ namespace A = N;
 
 A::X nx;
 
+namespace PR7014 {
+  namespace X
+  {
+    namespace Y {}
+  }
+
+  using namespace X;
+
+  namespace Y = X::Y;
+}