diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-10 22:04:13 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-10 22:04:13 +0000 |
commit | 7a73449b318225963dd9ceb4f75afe242ff21984 (patch) | |
tree | e2a4d93e10cd1b5df155cb3506ef7ae62b43b56c /clang/lib/Sema/SemaLookup.cpp | |
parent | bc68b431ba7c903f422d645ff08c146254a8f3d2 (diff) | |
download | bcm5719-llvm-7a73449b318225963dd9ceb4f75afe242ff21984.tar.gz bcm5719-llvm-7a73449b318225963dd9ceb4f75afe242ff21984.zip |
If we friend a declaration twice, that should not make it visible to name
lookup in the surrounding context. Slightly rework how we handle friend
declarations to inherit the visibility of the prior declaration, rather
than setting a friend declaration to be visible whenever there was a prior
declaration.
llvm-svn: 186040
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 8d954ca994c..0667b8adc04 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2757,8 +2757,15 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, bool Operator, // If the only declaration here is an ordinary friend, consider // it only if it was declared in an associated classes. if (D->getIdentifierNamespace() == Decl::IDNS_OrdinaryFriend) { - DeclContext *LexDC = D->getLexicalDeclContext(); - if (!AssociatedClasses.count(cast<CXXRecordDecl>(LexDC))) + bool DeclaredInAssociatedClass = false; + for (Decl *DI = D; DI; DI = D->getPreviousDecl()) { + DeclContext *LexDC = DI->getLexicalDeclContext(); + if (AssociatedClasses.count(cast<CXXRecordDecl>(LexDC))) { + DeclaredInAssociatedClass = true; + break; + } + } + if (!DeclaredInAssociatedClass) continue; } |