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 CheckFriendAccess(NamedDecl *D);
|
||||||
AccessResult CheckMemberAccess(SourceLocation UseLoc,
|
AccessResult CheckMemberAccess(SourceLocation UseLoc,
|
||||||
CXXRecordDecl *NamingClass,
|
CXXRecordDecl *NamingClass,
|
||||||
NamedDecl *D);
|
DeclAccessPair Found);
|
||||||
AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
|
AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
|
||||||
Expr *ObjectExpr,
|
Expr *ObjectExpr,
|
||||||
Expr *ArgExpr,
|
Expr *ArgExpr,
|
||||||
|
|
|
@ -1390,8 +1390,6 @@ static AccessResult IsAccessible(Sema &S,
|
||||||
CXXBasePath *Path = FindBestPath(S, EC, Entity, FinalAccess, Paths);
|
CXXBasePath *Path = FindBestPath(S, EC, Entity, FinalAccess, Paths);
|
||||||
if (!Path)
|
if (!Path)
|
||||||
return AR_dependent;
|
return AR_dependent;
|
||||||
if (Path->Access == AS_none) // This can happen during typo correction.
|
|
||||||
return AR_inaccessible;
|
|
||||||
|
|
||||||
assert(Path->Access <= UnprivilegedAccess &&
|
assert(Path->Access <= UnprivilegedAccess &&
|
||||||
"access along best path worse than direct?");
|
"access along best path worse than direct?");
|
||||||
|
@ -1716,14 +1714,14 @@ Sema::AccessResult Sema::CheckAllocationAccess(SourceLocation OpLoc,
|
||||||
/// \brief Checks access to a member.
|
/// \brief Checks access to a member.
|
||||||
Sema::AccessResult Sema::CheckMemberAccess(SourceLocation UseLoc,
|
Sema::AccessResult Sema::CheckMemberAccess(SourceLocation UseLoc,
|
||||||
CXXRecordDecl *NamingClass,
|
CXXRecordDecl *NamingClass,
|
||||||
NamedDecl *D) {
|
DeclAccessPair Found) {
|
||||||
if (!getLangOpts().AccessControl ||
|
if (!getLangOpts().AccessControl ||
|
||||||
!NamingClass ||
|
!NamingClass ||
|
||||||
D->getAccess() == AS_public)
|
Found.getAccess() == AS_public)
|
||||||
return AR_accessible;
|
return AR_accessible;
|
||||||
|
|
||||||
AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
|
AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
|
||||||
DeclAccessPair::make(D, D->getAccess()), QualType());
|
Found, QualType());
|
||||||
|
|
||||||
return CheckAccess(*this, UseLoc, Entity);
|
return CheckAccess(*this, UseLoc, Entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4409,7 +4409,7 @@ retry_lookup:
|
||||||
TRD != TRDEnd; ++TRD) {
|
TRD != TRDEnd; ++TRD) {
|
||||||
if (CheckMemberAccess(TC.getCorrectionRange().getBegin(),
|
if (CheckMemberAccess(TC.getCorrectionRange().getBegin(),
|
||||||
NSType ? NSType->getAsCXXRecordDecl() : 0,
|
NSType ? NSType->getAsCXXRecordDecl() : 0,
|
||||||
*TRD) == AR_accessible)
|
TRD.getPair()) == AR_accessible)
|
||||||
TC.addCorrectionDecl(*TRD);
|
TC.addCorrectionDecl(*TRD);
|
||||||
}
|
}
|
||||||
if (TC.isResolved())
|
if (TC.isResolved())
|
||||||
|
|
|
@ -135,3 +135,12 @@ void test() {
|
||||||
req.set_check(false); // expected-error-re {{use of undeclared identifier 'req'$}}
|
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