aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaAccess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaAccess.cpp')
-rw-r--r--clang/lib/Sema/SemaAccess.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index be30445d143c..580305c1110b 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/lib/Sema/SemaAccess.cpp
@@ -84,6 +84,20 @@ struct EffectiveContext {
: Inner(DC),
Dependent(DC->isDependentContext()) {
+ // An implicit deduction guide is semantically in the context enclosing the
+ // class template, but for access purposes behaves like the constructor
+ // from which it was produced.
+ if (auto *DGD = dyn_cast<CXXDeductionGuideDecl>(DC)) {
+ if (DGD->isImplicit()) {
+ DC = DGD->getCorrespondingConstructor();
+ if (!DC) {
+ // The copy deduction candidate doesn't have a corresponding
+ // constructor.
+ DC = cast<DeclContext>(DGD->getDeducedTemplate()->getTemplatedDecl());
+ }
+ }
+ }
+
// C++11 [class.access.nest]p1:
// A nested class is a member and as such has the same access
// rights as any other member.
@@ -1294,17 +1308,18 @@ static bool IsMicrosoftUsingDeclarationAccessBug(Sema& S,
SourceLocation AccessLoc,
AccessTarget &Entity) {
if (UsingShadowDecl *Shadow =
- dyn_cast<UsingShadowDecl>(Entity.getTargetDecl())) {
- const NamedDecl *OrigDecl = Entity.getTargetDecl()->getUnderlyingDecl();
- if (Entity.getTargetDecl()->getAccess() == AS_private &&
- (OrigDecl->getAccess() == AS_public ||
- OrigDecl->getAccess() == AS_protected)) {
- S.Diag(AccessLoc, diag::ext_ms_using_declaration_inaccessible)
- << Shadow->getUsingDecl()->getQualifiedNameAsString()
- << OrigDecl->getQualifiedNameAsString();
- return true;
+ dyn_cast<UsingShadowDecl>(Entity.getTargetDecl()))
+ if (UsingDecl *UD = dyn_cast<UsingDecl>(Shadow->getIntroducer())) {
+ const NamedDecl *OrigDecl = Entity.getTargetDecl()->getUnderlyingDecl();
+ if (Entity.getTargetDecl()->getAccess() == AS_private &&
+ (OrigDecl->getAccess() == AS_public ||
+ OrigDecl->getAccess() == AS_protected)) {
+ S.Diag(AccessLoc, diag::ext_ms_using_declaration_inaccessible)
+ << UD->getQualifiedNameAsString()
+ << OrigDecl->getQualifiedNameAsString();
+ return true;
+ }
}
- }
return false;
}