aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaAccess.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2021-05-19 13:31:13 -0700
committerRichard Smith <richard@metafoo.co.uk>2021-05-19 13:31:53 -0700
commitd38057f3ecb080e0ae4aba367a737226221327f2 (patch)
tree635172ededbba014be7af30928e08bcdeb67ab42 /clang/lib/Sema/SemaAccess.cpp
parent1dfa47910a2332a351ebc5236b4e2bfb3562c23b (diff)
downloadllvm-d38057f3ecb080e0ae4aba367a737226221327f2.zip
llvm-d38057f3ecb080e0ae4aba367a737226221327f2.tar.gz
llvm-d38057f3ecb080e0ae4aba367a737226221327f2.tar.bz2
Treat implicit deduction guides as being equivalent to their
corresponding constructor for access checking purposes.
Diffstat (limited to 'clang/lib/Sema/SemaAccess.cpp')
-rw-r--r--clang/lib/Sema/SemaAccess.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index be30445..3af0598 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.