forked from OSchip/llvm-project
Fix typo correction usage of SemaAccess.cpp.
When we check access for lookup results, make sure we propagate the result's access to the access control APIs; this can be different from the natural access of the declaration depending on the path used by the lookup. PR17394. llvm-svn: 191726
This commit is contained in:
parent
e4aaac506c
commit
3be1a1c0b5
|
@ -4896,7 +4896,7 @@ public:
|
|||
AccessResult CheckFriendAccess(NamedDecl *D);
|
||||
AccessResult CheckMemberAccess(SourceLocation UseLoc,
|
||||
CXXRecordDecl *NamingClass,
|
||||
NamedDecl *D);
|
||||
DeclAccessPair Found);
|
||||
AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
|
||||
Expr *ObjectExpr,
|
||||
Expr *ArgExpr,
|
||||
|
|
|
@ -1390,8 +1390,6 @@ static AccessResult IsAccessible(Sema &S,
|
|||
CXXBasePath *Path = FindBestPath(S, EC, Entity, FinalAccess, Paths);
|
||||
if (!Path)
|
||||
return AR_dependent;
|
||||
if (Path->Access == AS_none) // This can happen during typo correction.
|
||||
return AR_inaccessible;
|
||||
|
||||
assert(Path->Access <= UnprivilegedAccess &&
|
||||
"access along best path worse than direct?");
|
||||
|
@ -1716,14 +1714,14 @@ Sema::AccessResult Sema::CheckAllocationAccess(SourceLocation OpLoc,
|
|||
/// \brief Checks access to a member.
|
||||
Sema::AccessResult Sema::CheckMemberAccess(SourceLocation UseLoc,
|
||||
CXXRecordDecl *NamingClass,
|
||||
NamedDecl *D) {
|
||||
DeclAccessPair Found) {
|
||||
if (!getLangOpts().AccessControl ||
|
||||
!NamingClass ||
|
||||
D->getAccess() == AS_public)
|
||||
Found.getAccess() == AS_public)
|
||||
return AR_accessible;
|
||||
|
||||
AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
|
||||
DeclAccessPair::make(D, D->getAccess()), QualType());
|
||||
Found, QualType());
|
||||
|
||||
return CheckAccess(*this, UseLoc, Entity);
|
||||
}
|
||||
|
|
|
@ -4409,7 +4409,7 @@ retry_lookup:
|
|||
TRD != TRDEnd; ++TRD) {
|
||||
if (CheckMemberAccess(TC.getCorrectionRange().getBegin(),
|
||||
NSType ? NSType->getAsCXXRecordDecl() : 0,
|
||||
*TRD) == AR_accessible)
|
||||
TRD.getPair()) == AR_accessible)
|
||||
TC.addCorrectionDecl(*TRD);
|
||||
}
|
||||
if (TC.isResolved())
|
||||
|
|
|
@ -135,3 +135,12 @@ void test() {
|
|||
req.set_check(false); // expected-error-re {{use of undeclared identifier 'req'$}}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PR17394 {
|
||||
class A {
|
||||
protected:
|
||||
long zzzzzzzzzz;
|
||||
};
|
||||
class B : private A {};
|
||||
B zzzzzzzzzy<>; // expected-error {{expected ';' after top level declarator}}{}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue