diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2010-04-18 08:23:21 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2010-04-18 08:23:21 +0000 |
| commit | aad3007fe5e78d46beb82c8bcb89fe21731c5cdd (patch) | |
| tree | 4e1a2c3736f64f76855f327d1055774ce423b3e7 /clang/lib/Sema | |
| parent | 30b5277a0abf5452709cb261bc92c8cedae3a4bc (diff) | |
| download | bcm5719-llvm-aad3007fe5e78d46beb82c8bcb89fe21731c5cdd.tar.gz bcm5719-llvm-aad3007fe5e78d46beb82c8bcb89fe21731c5cdd.zip | |
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
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaAccess.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
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<FunctionDecl>(Ctx)) + DC = cast<DeclContext>(Ctx); + else if (FunctionTemplateDecl *FnTpl = dyn_cast<FunctionTemplateDecl>(Ctx)) + DC = cast<DeclContext>(FnTpl->getTemplatedDecl()); + EffectiveContext EC(DC); AccessTarget Target(DD.getAccessData()); |

