diff options
author | Jason Merrill <jason@redhat.com> | 2021-05-18 12:16:08 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-05-19 13:29:13 -0400 |
commit | 873c5188fd5d2e17430cab1522aa36fa62582ea7 (patch) | |
tree | 93c18935b80e58880cf781329b94043d85bfb90b /gcc/cp | |
parent | adcb497bdba499d161d2e5e8de782bdd6f75d62c (diff) | |
download | gcc-873c5188fd5d2e17430cab1522aa36fa62582ea7.zip gcc-873c5188fd5d2e17430cab1522aa36fa62582ea7.tar.gz gcc-873c5188fd5d2e17430cab1522aa36fa62582ea7.tar.bz2 |
c++: implicit deduction guides, protected access
Jonathan raised this issue with CWG, and there seems to be general agreement
that a deduction guide generated from a constructor should have access to
the same names that the constructor has access to. That seems to be as easy
as setting DECL_CONTEXT.
gcc/cp/ChangeLog:
* pt.c (build_deduction_guide): Treat the implicit deduction guide
as a member of the class.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction-access1.C: New test.
* g++.dg/cpp1z/class-deduction-access2.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/pt.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 23d2623..32cd0b7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -28803,6 +28803,9 @@ build_deduction_guide (tree type, tree ctor, tree outer_args, tsubst_flags_t com DECL_ABSTRACT_ORIGIN (ded_tmpl) = fn_tmpl; if (ci) set_constraints (ded_tmpl, ci); + /* The artificial deduction guide should have same access as the + constructor. */ + DECL_CONTEXT (ded_fn) = type; return ded_tmpl; } |