diff options
author | John McCall <rjmccall@apple.com> | 2009-12-11 02:33:26 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-12-11 02:33:26 +0000 |
commit | d7533ec10b618d360eb8952e62edb5657199acd3 (patch) | |
tree | b5a13cd97a5a596b40040b8f469749eafb294f56 /lib/Sema/SemaDeclCXX.cpp | |
parent | 60fa3cfd7aa63c29f9fc2d593bac56a3646337cc (diff) |
Check if the target of a using decl is already declared in this scope before
doing any of the other redeclaration checks. We were missing a few cases.
Fixes PR 5752.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 75021c2850..7d16e9b2b0 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2995,6 +2995,21 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig, if (isa<UsingShadowDecl>(Target)) Target = cast<UsingShadowDecl>(Target)->getTargetDecl(); + // If the target happens to be one of the previous declarations, we + // don't have a conflict. + // + // FIXME: but we might be increasing its access, in which case we + // should redeclare it. + NamedDecl *NonTag = 0, *Tag = 0; + for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); + I != E; ++I) { + NamedDecl *D = (*I)->getUnderlyingDecl(); + if (D->getCanonicalDecl() == Target->getCanonicalDecl()) + return false; + + (isa<TagDecl>(D) ? Tag : NonTag) = D; + } + if (Target->isFunctionOrFunctionTemplate()) { FunctionDecl *FD; if (isa<FunctionTemplateDecl>(Target)) @@ -3036,18 +3051,6 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig, // Target is not a function. - // If the target happens to be one of the previous declarations, we - // don't have a conflict. - NamedDecl *NonTag = 0, *Tag = 0; - for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); - I != E; ++I) { - NamedDecl *D = (*I)->getUnderlyingDecl(); - if (D->getCanonicalDecl() == Target->getCanonicalDecl()) - return false; - - (isa<TagDecl>(D) ? Tag : NonTag) = D; - } - if (isa<TagDecl>(Target)) { // No conflict between a tag and a non-tag. if (!Tag) return false; |