From aad3007fe5e78d46beb82c8bcb89fe21731c5cdd Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 18 Apr 2010 08:23:21 +0000 Subject: Fix the access checking of function and function template argument types, return types, and default arguments. This fixes PR6855 along with several similar cases where we rejected valid code. llvm-svn: 101706 --- clang/lib/Sema/SemaAccess.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 520a9708c6e..352477b8590 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -1015,8 +1015,15 @@ static Sema::AccessResult CheckAccess(Sema &S, SourceLocation Loc, void Sema::HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *Ctx) { // Pretend we did this from the context of the newly-parsed - // declaration. - EffectiveContext EC(Ctx->getDeclContext()); + // declaration. If that declaration itself forms a declaration context, + // include it in the effective context so that parameters and return types of + // befriended functions have that function's access priveledges. + DeclContext *DC = Ctx->getDeclContext(); + if (isa(Ctx)) + DC = cast(Ctx); + else if (FunctionTemplateDecl *FnTpl = dyn_cast(Ctx)) + DC = cast(FnTpl->getTemplatedDecl()); + EffectiveContext EC(DC); AccessTarget Target(DD.getAccessData()); -- cgit v1.2.3