summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-05-28 01:41:47 +0000
committerJohn McCall <rjmccall@apple.com>2010-05-28 01:41:47 +0000
commit4583186b8bfc138c0a7f108e2b44ebbd944a88eb (patch)
tree44d8d9e0f46c8082a3ce4de460dafe8f8e48f45c /clang/lib/Sema/SemaDeclCXX.cpp
parent3743b8cf49245d2da81bbf1bfc111651b82f825a (diff)
downloadbcm5719-llvm-4583186b8bfc138c0a7f108e2b44ebbd944a88eb.tar.gz
bcm5719-llvm-4583186b8bfc138c0a7f108e2b44ebbd944a88eb.zip
When filtering out previous declarations of friend functions, consider the
lookup context, not the direct semantic context. Fixes PR7230. llvm-svn: 104917
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9697f1357fe..8630e73ceea 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -5762,13 +5762,18 @@ Sema::ActOnFriendFunctionDecl(Scope *S,
LookupQualifiedName(Previous, DC);
- // If searching in that context implicitly found a declaration in
- // a different context, treat it like it wasn't found at all.
+ // Ignore things found implicitly in the wrong scope.
// TODO: better diagnostics for this case. Suggesting the right
// qualified scope would be nice...
- // FIXME: getRepresentativeDecl() is not right here at all
- if (Previous.empty() ||
- !Previous.getRepresentativeDecl()->getDeclContext()->Equals(DC)) {
+ LookupResult::Filter F = Previous.makeFilter();
+ while (F.hasNext()) {
+ NamedDecl *D = F.next();
+ if (!D->getDeclContext()->getLookupContext()->Equals(DC))
+ F.erase();
+ }
+ F.done();
+
+ if (Previous.empty()) {
D.setInvalidType();
Diag(Loc, diag::err_qualified_friend_not_found) << Name << T;
return DeclPtrTy();
OpenPOWER on IntegriCloud