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 | a17e83e437d69d8279c6e7abeae1ee6c07207f0b (patch) | |
| tree | 7e25b519e99e0c19ec49b9eab5b69cb9eb7bc174 /clang/lib/Sema/SemaDeclCXX.cpp | |
| parent | a009726ce3a05bf7412c7f6beefeda3c12788432 (diff) | |
| download | bcm5719-llvm-a17e83e437d69d8279c6e7abeae1ee6c07207f0b.tar.gz bcm5719-llvm-a17e83e437d69d8279c6e7abeae1ee6c07207f0b.zip | |
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.
llvm-svn: 91096
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 75021c28509..7d16e9b2b0f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/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; |

