aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-28 06:23:46 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-28 06:23:46 +0000
commit8d7ba402ba062994e242c97719685d6d66a056dd (patch)
treefa75733695ceac5214031fe8c9fdd0de6d10475d /lib/Sema/SemaDeclCXX.cpp
parent239a53edc946f3756635b2d230f62ed43dbbbef7 (diff)
Check that the namespace alias doesn't conflict with a previous declaration in this scope.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--lib/Sema/SemaDeclCXX.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 349aafdbda..4c8437deee 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1675,12 +1675,24 @@ void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) {
S->PushUsingDirective(UDir);
}
-Sema::DeclTy *Sema::ActOnNamespaceAliasDef(Scope *CurScope,
+Sema::DeclTy *Sema::ActOnNamespaceAliasDef(Scope *S,
SourceLocation AliasLoc,
IdentifierInfo *Alias,
const CXXScopeSpec &SS,
SourceLocation NamespaceLoc,
IdentifierInfo *NamespaceName) {
+
+ // Check if we have a previous declaration with the same name.
+ if (NamedDecl *PrevDecl = LookupName(S, Alias, LookupOrdinaryName)) {
+ // FIXME: If this is a namespace alias decl, and it points to the same
+ // namespace, we shouldn't warn.
+ unsigned DiagID = isa<NamespaceDecl>(PrevDecl) ? diag::err_redefinition :
+ diag::err_redefinition_different_kind;
+ Diag(AliasLoc, DiagID) << Alias;
+ Diag(PrevDecl->getLocation(), diag::note_previous_definition);
+ return 0;
+ }
+
return 0;
}