From: Abramo Bagnara Date: Sat, 26 Nov 2011 13:33:46 +0000 (+0000) Subject: Fixed lexical declaration context when instantiating a friend / out-of-line class... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c51548271d2f8385127e1d943764ae8939d7794;p=clang Fixed lexical declaration context when instantiating a friend / out-of-line class template member. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145146 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index c20033bbc2..9477192e23 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -862,9 +862,16 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { // Finish handling of friends. if (isFriend) { DC->makeDeclVisibleInContext(Inst, /*Recoverable*/ false); + Inst->setLexicalDeclContext(Owner); + RecordInst->setLexicalDeclContext(Owner); return Inst; } + if (D->isOutOfLine()) { + Inst->setLexicalDeclContext(D->getLexicalDeclContext()); + RecordInst->setLexicalDeclContext(D->getLexicalDeclContext()); + } + Owner->addDecl(Inst); if (!PrevClassTemplate) {