From c67b03260dbf4127e09b03302ff844a24e41394f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 26 Mar 2010 22:59:39 +0000 Subject: [PATCH] Compare namespaces properly when looking for redeclarations of 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 | 4 +++- test/SemaCXX/namespace-alias.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 1b4710e3d0..b5dc730522 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3736,8 +3736,10 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S, if (NamespaceAliasDecl *AD = dyn_cast(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(); } diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp index 06114c34cc..3ea1ccfd9f 100644 --- a/test/SemaCXX/namespace-alias.cpp +++ b/test/SemaCXX/namespace-alias.cpp @@ -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; + -- 2.40.0