7da4eae3dc
We set DECL_CONTEXT on implicitly generated deduction guides so that their access is consistent with that of the constructor. But this apparently leads to excessive instantiation in some cases, ultimately because instantiation of a deduction guide should be independent of instantiation of the resulting class specialization, but setting the DECL_CONTEXT of the former to the latter breaks this independence. To fix this, this patch makes push_access_scope handle artificial deduction guides specifically rather than setting their DECL_CONTEXT in build_deduction_guide. We could alternatively make the class befriend the guide via DECL_BEFRIENDING_CLASSES, but that wouldn't be a complete fix and would break class-deduction-access3.C below since friendship isn't transitive. PR c++/101174 gcc/cp/ChangeLog: * pt.c (push_access_scope): For artificial deduction guides, set the access scope to that of the constructor. (pop_access_scope): Likewise. (build_deduction_guide): Don't set DECL_CONTEXT on the guide. libstdc++-v3/ChangeLog: * testsuite/23_containers/multiset/cons/deduction.cc: Uncomment CTAD example that was rejected by this bug. * testsuite/23_containers/set/cons/deduction.cc: Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction-access3.C: New test. * g++.dg/cpp1z/class-deduction91.C: New test. |
||
---|---|---|
.. | ||
allocator | ||
capacity | ||
cons | ||
debug | ||
modifiers | ||
operations | ||
operators | ||
requirements | ||
14340.cc | ||
18604.cc | ||
23781_neg.cc | ||
48101_neg.cc | ||
48101-2_neg.cc | ||
48101-3_neg.cc | ||
58764.cc | ||
85965.cc | ||
92124.cc | ||
check_construct_destroy.cc | ||
erasure.cc | ||
init-list.cc | ||
move_comparison.cc | ||
pmr_typedefs_debug.cc | ||
pmr_typedefs.cc | ||
range_access.cc |