From cad7e43c5aba88bf6affc155b02d8609485db41b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 29 Apr 2013 10:13:55 +0000 Subject: Implement DR580: access checks for template parameters of a class template are performed within the context of that class template. Patch by Ismail Pazarbasi! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180707 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaAccess.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/Sema/SemaAccess.cpp') diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp index 79a9d3c9fd..3ef1fdebaa 100644 --- a/lib/Sema/SemaAccess.cpp +++ b/lib/Sema/SemaAccess.cpp @@ -84,10 +84,10 @@ struct EffectiveContext { : Inner(DC), Dependent(DC->isDependentContext()) { - // C++ [class.access.nest]p1: + // C++11 [class.access.nest]p1: // A nested class is a member and as such has the same access // rights as any other member. - // C++ [class.access]p2: + // C++11 [class.access]p2: // A member of a class can also access all the names to which // the class has access. A local class of a member function // may access the same names that the member function itself @@ -1476,18 +1476,18 @@ static Sema::AccessResult CheckAccess(Sema &S, SourceLocation Loc, llvm_unreachable("falling off end"); } -void Sema::HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *decl) { +void Sema::HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *D) { // Access control for names used in the declarations of functions // and function templates should normally be evaluated in the context // of the declaration, just in case it's a friend of something. // However, this does not apply to local extern declarations. - DeclContext *DC = decl->getDeclContext(); - if (FunctionDecl *fn = dyn_cast(decl)) { - if (!DC->isFunctionOrMethod()) DC = fn; - } else if (FunctionTemplateDecl *fnt = dyn_cast(decl)) { - // Never a local declaration. - DC = fnt->getTemplatedDecl(); + DeclContext *DC = D->getDeclContext(); + if (FunctionDecl *FN = dyn_cast(D)) { + if (!DC->isFunctionOrMethod()) + DC = FN; + } else if (TemplateDecl *TD = dyn_cast(D)) { + DC = cast(TD->getTemplatedDecl()); } EffectiveContext EC(DC); -- cgit v1.2.3-70-g09d2