[cfe-commits] r99664 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/namespace-alias.cpp
Douglas Gregor
dgregor at apple.com
Fri Mar 26 15:59:39 PDT 2010
Author: dgregor
Date: Fri Mar 26 17:59:39 2010
New Revision: 99664
URL: http://llvm.org/viewvc/llvm-project?rev=99664&view=rev
Log:
Compare namespaces properly when looking for redeclarations of
namespace aliases. Fixes PR6341.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/namespace-alias.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=99664&r1=99663&r2=99664&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Mar 26 17:59:39 2010
@@ -3736,8 +3736,10 @@
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();
}
Modified: cfe/trunk/test/SemaCXX/namespace-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/namespace-alias.cpp?rev=99664&r1=99663&r2=99664&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/namespace-alias.cpp (original)
+++ cfe/trunk/test/SemaCXX/namespace-alias.cpp Fri Mar 26 17:59:39 2010
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-namespace N { };
+namespace N { struct X { }; };
namespace A = N;
@@ -83,3 +83,11 @@
KC::func(); // expected-error {{undeclared identifier 'KC'}}
}
}
+
+// PR6341
+namespace A = N;
+namespace N { }
+namespace A = N;
+
+A::X nx;
+
More information about the cfe-commits
mailing list