]> granicus.if.org Git - clang/commitdiff
Compare namespaces properly when looking for redeclarations of
authorDouglas Gregor <dgregor@apple.com>
Fri, 26 Mar 2010 22:59:39 +0000 (22:59 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 26 Mar 2010 22:59:39 +0000 (22:59 +0000)
namespace aliases. Fixes PR6341.

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

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

index 1b4710e3d085ca33904d418a3eae7bdd698ce858..b5dc73052282b6986b20a126df948c7e3e9149f0 100644 (file)
@@ -3736,8 +3736,10 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
     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.
+      // FIXME: At some point, we'll want to create the (redundant)
+      // declaration to maintain better source information.
       if (!R.isAmbiguous() && !R.empty() &&
-          AD->getNamespace() == getNamespaceDecl(R.getFoundDecl()))
+          AD->getNamespace()->Equals(getNamespaceDecl(R.getFoundDecl())))
         return DeclPtrTy();
     }
 
index 06114c34cc4784a8e23df88dd9c7f632df50e30e..3ea1ccfd9f70a6a3db4ff3e24e82486ff5d1703a 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-namespace N { };
+namespace N { struct X { }; };
 
 namespace A = N;
 
@@ -83,3 +83,11 @@ namespace K {
     KC::func(); // expected-error {{undeclared identifier 'KC'}}
   }
 }
+
+// PR6341
+namespace A = N;
+namespace N { }
+namespace A = N;
+
+A::X nx;
+