diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-07-16 07:45:46 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-07-16 07:45:46 +0000 |
commit | b02ef242c76f718a33ec3d9e42f9dbabaf5856b9 (patch) | |
tree | 2293dc4334aa9c26795fa78532ca27c037ceab1b /lib/Sema/SemaDecl.cpp | |
parent | d7464be9829a0a8557636a14d17dd9d56594b911 (diff) |
When checking for name collision between a tag and a previously defined namespace, the collision occured even when the tag was in a different nested scope.
Fix it by taking into account the scope when checking for namespace-tag name collisions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 4836be4b8e..f4d9da6014 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1733,11 +1733,14 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK, // scope, e.g. "struct foo; void bar() { struct foo; }", just create a new // type. } else { - // The tag name clashes with a namespace name, issue an error and recover - // by making this tag be anonymous. - Diag(NameLoc, diag::err_redefinition_different_kind, Name->getName()); - Diag(PrevDecl->getLocation(), diag::err_previous_definition); - Name = 0; + // PrevDecl is a namespace. + if (IdResolver.isDeclInScope(PrevDecl, CurContext, S)) { + // The tag name clashes with a namespace name, issue an error and recover + // by making this tag be anonymous. + Diag(NameLoc, diag::err_redefinition_different_kind, Name->getName()); + Diag(PrevDecl->getLocation(), diag::err_previous_definition); + Name = 0; + } } } |