diff options
author | John McCall <rjmccall@apple.com> | 2009-08-31 22:39:49 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-08-31 22:39:49 +0000 |
commit | 759e32bdc69968ec9ada4781b34894bb72fede43 (patch) | |
tree | 82008704a63ae44cfde4768312cfc13db16f3701 /clang/lib/Sema/SemaDeclCXX.cpp | |
parent | 124095bb18fcd56e53d80a156199995096f3ff0f (diff) | |
download | bcm5719-llvm-759e32bdc69968ec9ada4781b34894bb72fede43.tar.gz bcm5719-llvm-759e32bdc69968ec9ada4781b34894bb72fede43.zip |
Fix bug 4784 and allow friend declarations to properly extend
existing declaration chains.
llvm-svn: 80636
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c729b6a7c75..4acde29b7b5 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3820,15 +3820,27 @@ Sema::DeclPtrTy Sema::ActOnFriendFunctionDecl(Scope *S, IsDefinition, Redeclaration); if (!ND) return DeclPtrTy(); + + assert(cast<FunctionDecl>(ND)->getPreviousDeclaration() == FD && + "lost reference to previous declaration"); + FD = cast<FunctionDecl>(ND); assert(FD->getDeclContext() == DC); assert(FD->getLexicalDeclContext() == CurContext); - // We only add the function declaration to the lookup tables, not - // the decl list, and only if the context isn't dependent. - if (!CurContext->isDependentContext()) - DC->makeDeclVisibleInContext(FD); + // Add the function declaration to the appropriate lookup tables, + // adjusting the redeclarations list as necessary. We don't + // want to do this yet if the friending class is dependent. + // + // Also update the scope-based lookup if the target context's + // lookup context is in lexical scope. + if (!CurContext->isDependentContext()) { + DC = DC->getLookupContext(); + DC->makeDeclVisibleInContext(FD, /* Recoverable=*/ false); + if (Scope *EnclosingScope = getScopeForDeclContext(S, DC)) + PushOnScopeChains(FD, EnclosingScope, /*AddToContext=*/ false); + } FriendDecl *FrD = FriendDecl::Create(Context, CurContext, D.getIdentifierLoc(), FD, |